Skip to content

Add the packaging for avocado-ext-container-agent-dev - #1

Merged
jetm merged 21 commits into
mainfrom
seed-container-agent-dev
Sep 15, 2026
Merged

jetm merged 21 commits into
mainfrom
seed-container-agent-dev

Conversation

@jetm

@jetm jetm commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Problem

avocado-ext-container-agent-dev existed only under avocado-os/extensions/.
That is why it has never appeared in a feed: publishing runs from an ext-*
repo's own release workflow, and this extension had no repo to run one from. The
downstream effect is that the Container Dev Mode guide and its two field notes
are still draft: true on the docs site, because they have readers add an
extension nobody can install.

Solution

Fill in the template with the extension's packaging, and bring the crate across
with its history rather than as a flat copy - git log agent/ still explains why
the code looks the way it does.

Key changes

  • agent/ - the Rust crate, imported via subtree so all 19 of its commits remain
    reachable.
  • cad-compile.sh, cad-install.sh, cad-clean.sh - build hooks.
  • overlay/ - the container-agent-dev path and service units.
  • avocado.yaml - manifest, adapted to the template's conventions.
  • release.yml - one matrix row per declared target, fail-fast: false.
  • .gitignore - the repo had none; covers the crate's build output and the
    generated cross-compilation config.

Three deliberate differences from the in-tree version

Triple resolution refuses an ambiguous match. The in-tree loop takes the
first target JSON whose basename starts with $OECORE_TARGET_ARCH- and discards
the rest silently, so a wrong-architecture binary packages, publishes and
installs successfully and fails only when the device execs it. This version
enumerates and refuses on more than one candidate.

It also skips the SDK's own nativesdk triple. Without that, x86_64 resolves to
two candidates - x86_64-avocado-linux-gnu and x86_64-avocadosdk-linux-gnu -
and refuses. Worth knowing: the in-tree version picks the right one only because
avocado- sorts ahead of avocadosdk- on the hyphen. Nothing enforces that, and
it affects every target whose architecture matches the SDK host architecture.

supported_targets lists targets instead of '*'. The wildcard claimed
every machine in the platform on the evidence of one having been built, and the
feed carries no repo at all for several machines it covered. It now names
qemux86-64 and imx93-frdm, and should grow only as targets are actually
built.

The SDK image is release-scoped from the environment, matching the template.
The in-tree version appended the channel, which resolves to a tag that does not
exist for any release except 2024.

Verification

From a clean clone, sdk install, ext install and ext build all succeed for
qemux86-64, producing ELF 64-bit LSB pie executable, x86-64 from
resolved-target: x86_64-avocado-linux-gnu, with both the sysext and confext
extensions built.

The resolution path also has a fixture covering four candidate shapes - zero,
one, two, and the sdk-plus-device pair - across both scripts. It exists because
no published feed carries a 32-bit ARM target, so the multi-candidate refusal
cannot be exercised against a real SDK.

Reviewer notes

  • The matrix targets 2024/next. The 2026 feed currently carries only
    jetson-agx-thor, qemuarm64 and qemux86-64, so an imx93-frdm row there
    would fail; there is a commented row to enable when that changes.
  • AVOCADO_CONNECT_TOKEN and AVOCADO_CONNECT_ORG need to exist as secrets on
    this repo before a tag will publish.
  • Nothing removes the copy under avocado-os/extensions/ yet. That should wait
    until this repo has actually published, so image composition keeps working in
    the meantime.
  • The extension requires the docker extension in the same runtime. That
    dependency is stated in the manifest and README rather than declared, because
    avocado-cli parses an inter-extension dependency and logs it without
    installing anything.

jetm added 21 commits August 18, 2026 13:46
There was no device-side component to connect to the host's control
WebSocket in container dev mode. Without it, the device has no way to
receive image sync notifications from the host or report its current
running state, making the live-reload workflow incomplete.

Introduce a Rust binary (`avocado-container-agent-dev`) that runs on
the device. It reads a bootstrap file written by the host, establishes
a TLS-secured WebSocket connection to the host's control endpoint, and
sends a `Hello` frame carrying the device's identity, CPU architecture,
and currently running image digest. The agent then holds the connection
and processes incoming `HostFrame::Sync` notifications, with a clear
seam left for the pull-and-restart logic to be filled in a later task.
Reconnections use exponential backoff that resets on a successful link,
so a device that briefly loses connectivity recovers quickly without
hammering the host.

TLS is pinned to the ring crypto provider exclusively, with the
bootstrap CA as the only trust anchor, matching the constraint enforced
elsewhere in the project for musl cross-compilation targets where
`aws-lc-rs` is unavailable. The ring provider is also installed as the
process-wide default as a defense-in-depth measure.

Signed-off-by: Javier Tia <javier@peridio.com>
Container engines (docker/podman) require either an insecure-registry
flag or a per-engine trust/cert file to pull from any non-loopback HTTP
registry. Neither is acceptable in a zero-touch device deployment where
we cannot assume engine configuration is modifiable. Without a solution,
the agent cannot serve images to the on-device engine without requiring
privileged engine reconfiguration.

Introduce a plain-HTTP loopback registry proxy that the device engine
pulls from without any trust configuration, since engines automatically
trust loopback addresses. Each OCI read request arriving on
`127.0.0.1:15151` is forwarded over a pinned-CA HTTPS connection to the
host bulk listener, carrying the read/control Bearer token. Blob bytes
travel this direct HTTPS path and never ride the control WebSocket,
matching the design's bulk/control split. The proxy fails closed
pre-stream: the upstream status is inspected before any engine-facing
`200` is opened, so a stale-token `401`/`403` from the upstream never
triggers an engine retry loop. When the token is rejected the proxy
raises a shared `ReBootstrap` flag the agent surfaces to the host as a
`Status` frame on the next reconnect, directing the operator to re-run
`avocado container dev up`. Upstream `WWW-Authenticate` headers are
dropped via a strict passthrough allowlist and never reach the engine
under any status code.

Signed-off-by: Javier Tia <javier@peridio.com>
Currently the Sync frame handler in the container dev-mode agent is a
stub that logs the received fields but performs no actual work. Without
a real implementation, the device can never apply a new container image
when the host requests a sync: the pull is skipped, the active-image
pointer on the writable partition is never updated, and the container
continues running the old image indefinitely.

Introduce a sync module that implements the full ordered sequence for
task 6.3: pull the new image through the device loopback proxy, rewrite
the active-image pointer JSON on the writable partition, restart the
container, and update the in-memory running digest so the next reconnect
Hello reports the correct image. The ordering is load-bearing: a pull
failure aborts the entire sequence before any state is mutated, ensuring
the device never claims a new image is running when it is not. The
writable partition root is structurally enforced at the type level so
pointer writes can never land on a read-only rootFS path.

The container engine interaction is hidden behind an Engine trait,
mirroring the proxy Upstream pattern from task 6.2. The production
CommandEngine shells out to docker or podman via tokio::process and is
the only untested portion; the ordering, pointer round-trip, digest
update, and pull-failure abort paths are all covered by unit tests
using an in-process FakeEngine. The tempfile crate is added as a
dev-dependency to supply a writable temporary directory in those tests.

Signed-off-by: Javier Tia <javier@peridio.com>
There is currently no device-side component to support the Container
Dev Mode workflow. Without an agent running on the device, there is
no way to establish a control channel back to the host CLI, proxy
image pulls through the bootstrap-delivered CA, or hot-reload the
target container when source is synced.

Introduce a self-contained Avocado extension that builds and installs
a Rust agent exclusively for development runtimes. The extension
declares its own SDK dependencies for cross-compilation, provides
build and clean scripts that resolve the correct Rust target from
the SDK environment, and installs the resulting binary under
/usr/bin. A systemd service activates the agent on boot but remains
inert until the bootstrap payload written by `avocado container dev up`
is present on the writable partition, ensuring the unit does nothing
on devices that have never been enrolled in a dev session. The
extension is intentionally absent from production images by design.

Signed-off-by: Javier Tia <javier@peridio.com>
The device agent must stay on the ring rustls provider because it
cross-compiles against the musl SDK, which clears only the ring stack;
aws-lc-rs is forbidden. Nothing enforced this beyond ad-hoc checks, so a
dependency bump could silently pull aws-lc-rs back in and break the
cross-compile with no gate.

Add check-provider.sh with a three-way exit contract: it fails when
aws-lc-rs resolves into the tree, passes only when cargo reports the
package provably absent, and treats any other resolution failure
(network, bad manifest, unresolvable target) as a loud guard error
rather than a false pass. A ring-present backstop ensures a guard that
cannot see the tree can never masquerade as success.

Signed-off-by: Javier Tia <javier@peridio.com>
The guard script is only useful if something runs it. avocado-os has no
CI or pre-commit, so the extension's cross-build hook is the natural gate.

Invoke check-provider.sh from cad-compile.sh with TARGET set to the
resolved SDK cross target, immediately before cargo build and after the
target resolution and CARGO_HOME export, so the guard resolves the same
manifest, target, and registry cache the build uses. A reintroduced
aws-lc-rs now fails the image build. Document that the in-hook run is the
enforced gate and a bare standalone run is host-triple advisory.

Signed-off-by: Javier Tia <javier@peridio.com>
on_sync wrote active-image.json before calling engine.restart(), so a
restart failure returned with the pointer already claiming the new image
while the container still ran the old one. running_digest stayed honest,
which left the two records disagreeing until the next successful sync -
and the pointer is the one an operator reads off the device to answer
"what is this thing running".

Swap the order. The pointer records what the device IS running, so it has
no reason to precede the thing that makes that true; nothing consumes it
during container startup, so moving it later costs no behaviour. The new
test drives a restart failure and asserts the pointer is absent and the
digest unmoved, which fails against the previous ordering.

Signed-off-by: Javier Tia <javier@peridio.com>
serve() propagated any accept() error out of the loop, and main only logs
that the proxy exited without respawning it. One transient failure - fd
exhaustion, a peer that vanished between the SYN and the accept - therefore
disabled the registry proxy for the rest of the process lifetime, so every
later Sync pull failed connection-refused with no recovery short of
restarting the unit. A per-accept error says nothing about the listener, so
it should not be treated as fatal to it.

Log and continue, with a short pause first so a sustained EMFILE spins the
task instead of the CPU.

Also record the two properties of this proxy that read as defects until you
know why they are not: the loopback listener performs no device-side authz
(a device-side gate needs a credential the engine would then have to be
configured with, which is the per-engine trust file the design exists to
avoid), and each upstream request opens a fresh TLS connection (a pool needs
eviction and reuse-after-error handling for a handful of handshakes per sync
on a dev-only path). Both are bounded rather than free, so the reasoning
belongs next to the code that will otherwise attract the same finding again.

Signed-off-by: Javier Tia <javier@peridio.com>
Making every accept error a `continue` traded one failure mode for a worse
one. A listener that fails permanently - EBADF, or any error that repeats -
now produced a 10 Hz warn stream forever, and because the loop could never
return, the process never exited and `Restart=always` had nothing to restart.
The previous `?` at least let systemd recover. It also made `serve`'s error
variant and main's "loopback registry proxy exited" branch unreachable.

Retry a bounded run instead: a counter reset by any successful accept, and
after 32 consecutive failures the error propagates so the supervisor can do
its job. That keeps the resilience the change was for - a peer vanishing
between SYN and accept, a momentary EMFILE - without disabling recovery for
the case where the listener is genuinely gone.

The EMFILE motivation is better served at the source, so the unit now sets
LimitNOFILE=65536 rather than relying on this loop to absorb fd exhaustion.

Also move ACCEPT_ERROR_BACKOFF below REBOOTSTRAP_MSG. Inserting it where it
was put the const between REBOOTSTRAP_MSG's doc comment and REBOOTSTRAP_MSG
itself, so `cargo doc` and editor hover described a 100ms sleep as the
plain-text body returned when the bulk upstream rejects a token, and
REBOOTSTRAP_MSG was left undocumented.

Signed-off-by: Javier Tia <javier@peridio.com>
…the write

Moving the pointer write after the restart fixed a pointer that claimed an
image the device was not running, and opened the inverse: a restart that
succeeds followed by a pointer write that fails - ENOSPC, an unwritable /var -
bailed on the `?` before `running_digest` was updated, so the reconnect Hello
reported the OLD digest while the container ran the new one. Same skew, other
direction, and only the first direction had a test.

Set `running_digest` immediately after the restart returns. At that instant
the container really is running the new image; that is something observed, not
something planned, so nothing downstream should be able to make the agent
report otherwise. A device contradicting itself is worse than a stale pointer
- the host would keep re-syncing an image the device already runs.

The pointer write is then reported rather than propagated. The pull and the
restart both succeeded, so the sync did take effect; failing the whole
operation over the bookkeeping record would tell the host the opposite, and
its only recovery is to retry the same digest, which does not fix a full disk.

The new test drives exactly that path - a writable_root whose parent is a file,
so create_dir_all cannot succeed while pull and restart do - and asserts the
digest still reports the running image. It fails against the previous
propagate-and-defer ordering.

Signed-off-by: Javier Tia <javier@peridio.com>
The previous unit sat in the worst quadrant: sandboxed enough to break rootful
podman, not sandboxed enough to confine anything. Both cannot be fixed at once.
systemd.exec(5) is explicit that ProtectSystem is undone by a privileged
process without CapabilityBoundingSet=~CAP_SYS_ADMIN - root can remount its own
read-only binds - and rootful podman needs precisely CAP_SYS_ADMIN, plus
namespaces, cgroup writes and kernel knobs, all in-process. Supporting podman
means the sandbox is decorative; a real sandbox means podman cannot run here.

Choosing the sandbox. The agent takes an empty capability bounding set,
ProtectSystem=strict with StateDirectory as its only writable path, plus
namespace, cgroup and kernel protections and an @System-service syscall filter.
UMask=0077 because the state directory holds the Bearer token and the session
CA, and systemd-analyze flagged the default as world-readable.

Docker is unaffected. Its daemon is a separate unit holding the privilege and
is reached over an AF_UNIX socket, and a read-only mount does not block
connect() to a socket - the exemption is in sb_permission(), which only rejects
writes to regular files, directories and symlinks. AF_NETLINK comes back out of
the allowlist: it was only ever needed by netavark configuring a podman
container's netns.

systemd-analyze security now scores this unit 2.7 (OK), against a prior
configuration where the strongest directives were being silently undone.

The agent warns at startup when the engine is podman. Without it the failure is
invisible in the worst way: podman fails at store init, on_sync's error is only
logged by its caller, and every Sync silently no-ops while the agent stays
connected reporting a stale digest. A warning rather than a refusal, because
the restriction belongs to the unit and not to the binary - run directly for
debugging, podman is fine.

Restoring podman properly needs the engine out of this process rather than a
weaker unit, and is tracked separately.

Signed-off-by: Javier Tia <javier@peridio.com>
The bounded retry shipped verified by inspection only, because forcing repeated
accept() failures on a real TcpListener means corrupting its fd, which is not
portable. So the whole accept loop had no coverage at all - not just the new
branch.

An `Accept` seam fixes that, mirroring the `Upstream` trait this module already
uses for the same reason: production keeps its TcpListener, tests supply a
listener whose failures are scripted.

Two properties, both confirmed to fail when their mechanism is removed. A
permanently failing listener must end the loop, so the process exits and
Restart=always can recover it - with the bound removed this hangs instead of
terminating. And a success must reset the counter, or a long-lived proxy
accumulating scattered transient errors would eventually shut itself down for
no reason; the fixture puts one success between two runs of 31 failures, so
neither run reaches the limit of 32 alone but their sum does, and removing the
reset fails with "gave up after 33 accepts".

The counter-reset case is the one worth having. The threshold is arithmetic
anyone can read; a counter that quietly fails to reset is not, and it is the
half that turns a resilience feature into a spurious shutdown.

Signed-off-by: Javier Tia <javier@peridio.com>
The bounded accept retry could never reach `Restart=always`, so the whole
mechanism - and the two tests protecting it - rested on a claim that was false
end to end. `serve_loopback` ran in a detached `tokio::spawn` whose `JoinHandle`
was dropped, and `main` then blocked forever in `run()`. `serve_on` returning
Err killed only its own task: the process stayed alive, systemd saw a healthy
unit, and every later Sync failed connection-refused against a proxy that was
gone while the agent kept reporting a stale digest.

I asserted the opposite in a commit body, in two comments, and in a review
reply I used to resolve the thread. The review that raised it was wrong in the
same place - it held that the previous `?` "would have exited and let systemd
recover", but that error was discarded identically, so the `?` never exited
either. Neither of us checked what `main` did with the task.

`end_when_either_ends` selects the proxy against the WS loop so whichever ends
first ends `main`, and is a named function rather than an inline select so the
seam is testable. Three tests cover it, all failing when the select is replaced
by the old ignore-the-proxy behaviour. A cleanly stopped proxy is fatal too: no
pull can succeed without it, so being rebuilt beats serving a control WS that
can only report failures.

The podman warning moves to startup, where it was documented to be. It ran from
`CommandEngine::from_env`, constructed once per Sync frame, so `systemctl start`
with an engine override logged nothing - the one moment it was new information -
and then repeated before every pull failure. `is_unsupported_engine` is pure and
tested; `main` calls it once.

Also pins the accept backoff, which had no coverage: deleting the sleep left all
ten proxy tests green while it is the only thing preventing a busy spin. Virtual
time (`start_paused`) asserts the elapsed backoff without spending it, which
takes the suite from 6.17s to 0.01s and fails with "only 0ns elapsed" when the
sleep is removed.

Smaller corrections from the same review: the unit's comment claimed
StateDirectory was the only writable path, which ignored PrivateTmp's private
/tmp - it now says persistent and names the difference, since that sentence is
what a future reader will trust. A doc referenced a constructor name that does
not exist. `serve` had become a verbatim forwarder with one caller. And
`libc_ebadf()` returned a bare 9 while implying it read libc, for a value no
assertion depends on.

Signed-off-by: Javier Tia <javier@peridio.com>
One unconditional info! sat after the match on write_active_image, so on
an ENOSPC /var the journal emitted the warning and then "sync complete:
pulled, pointer rewritten, container restarted" immediately below it.
Grepping the success line - the obvious thing to grep - reported a current
pointer when no file had been written. The warning was right there, but
between the two it is the success line that reads as authoritative.

Give each outcome its own terminal line and keep the phrase "sync
complete" on the Ok arm only. The failure path now says "sync incomplete"
and names what is missing, so grepping either string answers truthfully
rather than needing the neighbouring line for context.

Fix the docs the step reorder left behind. Recording the digest ahead of
the pointer write renumbered the inline comments but not the module doc,
whose steps 3 and 4 still read pointer-then-digest, nor on_sync's own doc,
which said "pull -> rewrite pointer -> restart -> record digest" and so
described neither the old body nor the new one. Both now state the real
order and, more usefully, the consequence it creates: the pointer write is
the only step allowed to fail while the sync returns Ok, so nothing may
assume the pointer file exists just because the digest is set. That is the
interaction the reorder introduced, which is what made the stale doc worse
than a normal one - a reader adding a step between 3 and 4 would have
placed a guard on a file that may not be there.

No test covers log wording: this crate has no tracing subscriber harness,
so the two arms are verified by inspection rather than assertion. The
existing restart_failure_leaves_no_stale_pointer test still covers the
branch being logged from. fmt, clippy -D warnings and all 34 tests pass.

Signed-off-by: Javier Tia <javier@peridio.com>
…ly runs

`<engine> restart <container>` re-executes the container's existing config,
and that config pins the image by ID at create time. A sync therefore pulled
the new image, restarted the container onto the OLD one, and reported
success: the device kept running the previous build while the host, the
control frame and the active-image pointer all agreed the reload had landed.
Silent staleness is the worst shape this failure could take, because nothing
in the loop contradicts it.

Restart the systemd unit that launched the container instead, when one is
named. The unit re-runs `<engine> run` on restart, which re-resolves the tag
and so adopts whatever the pull just fetched. Gating it on an env var rather
than always shelling to `systemctl` keeps a device that starts its container
by hand on the previous behaviour, and the var carries the same value the
`service:` field under `container_dev.images` already declares, so nothing
new has to be configured to use it.

Signed-off-by: Javier Tia <javier@peridio.com>
The pull is digest-pinned, so it lands on the device as an untagged image. The
unit's ExecStart names `<image>:<tag>`, and nothing ever connected the two: on a
device that had the tag from an earlier build the restart re-ran the OLD image, and
on one that never had it the restart could not resolve the ref at all. The agent
logged "sync complete: pulled, container restarted" in both cases, so the failure
was invisible from every side - host, control frame and pointer all agreed a reload
had happened.

Tag the pulled reference as `<image>:<tag>` between the pull and the restart, so
the ref the service names resolves to the image just fetched.

This went unnoticed because the only topology exercised so far built the image on
the device itself, through a forwarded engine socket. There the tag already existed
and already pointed at the new build, so the restart picked it up and the pull was
redundant - the delivery path was never actually under test. Running the host as
the builder, with the device able to obtain the image only through the loop, fails
without this and succeeds with it: a device wiped of every my-app image ends up
running the host's build.

Signed-off-by: Javier Tia <javier@peridio.com>
The two defects at the top mean the documented flow never worked at all,
and both failed with every layer reporting success.

The agent never started. `on_merge` ran `systemctl start` at extension-merge
time, before any bootstrap existed, so the unit's own ConditionPathExists
skipped it - and nothing re-triggered a start once the bootstrap landed,
because `avocado container dev up` delivers that file over SSH and issues
no systemctl call anywhere in its container-dev paths. Restart=always does
not help a unit that never reached a running state. A .path unit fixes
this at the level the problem lives on: it has no condition, so it starts
at merge time, and it activates the service the moment the file appears.

And a sync that ran adopted nothing. Nothing sets
AVOCADO_CONTAINER_DEV_SERVICE, so `restart()` always took the
`<engine> restart <container>` branch that the code's own comment
describes as a no-op - the container object stays bound to its create-time
image id and does not re-resolve the tag. The pull, the tag and the restart
all succeeded, the new digest was recorded, the pointer claimed it, and the
host's reconcile saw its desired state satisfied. The sync now proves
adoption by comparing image ids and fails naming the remedy, which catches
it on whichever branch produced it rather than trusting the branch.

Four more ways the agent reported health it did not have. A failed sync was
swallowed into a warn!, so with Hello re-sent only on reconnect the host
went on showing the device synced at the old digest; failures now go back
as a Status frame. The re-bootstrap flag was read once per session BEFORE
the frame loop, while the 401 that raises it happens during a pull inside
that loop - so it was set strictly after the only read that would have sent
it, and nothing could lower it, so one transient 401 latched forever. A
failed upstream build logged one warning and carried on with no proxy,
three lines below a comment arguing at length that losing the proxy must
end the process; that path is now as fatal as the one the comment covers.
And no engine check ran at all, so merging without the docker extension
left the unit active and silent until the first sync hit ENOENT.

Three that turn a transient into a permanent failure. No upstream stage had
a timeout, and with no SO_KEEPALIVE and a purely reading socket after
send_request, a laptop that sleeps mid-pull wedged the agent forever with
systemd reporting active (running). The backoff reset on any completed
handshake, so a host that accepts the upgrade and then panics pinned the
device to a ~1 Hz TLS handshake loop; it now needs a session that lasted.
Syncs ran inline in the WS read loop, so nothing was read for the duration
of a pull and N saves queued N full pull/tag/restart cycles - they run on
their own task now, with a latest-wins slot, because only the newest digest
is worth applying.

The bootstrap was never re-read, which made the recovery every message
recommends impossible: re-running `up` mints a token the agent does not
have, so both legs 401 and the loop spins without ever exiting. The agent
now exits when the file changes, which re-reads the proxy's copy of the
token too.

RestartSec=5 against the default 10s/5 start limit put two starts in any
window, so a unit failing instantly on malformed JSON sat in
activating (auto-restart) indefinitely and never reached failed. Widening
the interval makes the limit reachable. Both keys go in [Unit]: systemd
moved them in v229 and silently ignores them under [Service], which is
where they landed first and what `systemd-analyze verify` caught.

FakeEngine could not fail the tag step, so the `?` on engine.tag had no
coverage - replacing it with `let _ =` left all eight sync tests green.

Signed-off-by: Javier Tia <javier@peridio.com>
…body read

The adoption probe added last commit proves a restart took effect, but
nothing could satisfy it. `docker restart` re-executes the existing
container object, which stays bound to its create-time image id, and the
shipped unit exports only RUST_LOG and AVOCADO_CONTAINER_DEV_ENGINE - so
`service_from_env()` was always None, every device took the container
branch, and the probe turned a silent no-op into a sync that fails
forever. Its `if let (Some, Some)` guard also skipped the check whenever
either id was unknown, so a device with no container at all passed
vacuously and recorded the new digest while running nothing: the same
false success, reached through the other door, covering exactly the
population the mismatch arm does not.

The host already parses the answer. Each `container_dev.images` entry
declares the `service:` that consumes the image, so carry it on the Sync
frame rather than depending on an operator exporting an env var nothing
documents at the point of use. The field is optional, so a device running
against a host that does not send it yet parses the frame and falls back
to the env override and then to the container branch, exactly as before.
Absence of a container is now a failure rather than a pass, with a
bounded wait first because `systemctl restart` returns before a
Type=simple unit has necessarily created anything.

Three lifetime bugs around the sync worker went with it. The worker was
aborted after the serve loop, reachable only by falling out of it, while
three `?` sites returned early instead - and the stream read is the
common session end, since tungstenite yields Some(Err(..)) on a reset and
None only on a clean close. That leaked a parked task per errored session
and let a surviving worker's pull/tag/restart race the next session's on
running_digest and the pointer file. A guard makes the abort unreachable
to skip; it holds an AbortHandle rather than the JoinHandle because the
session never joins the worker, which also lets a test keep the
JoinHandle and await the cancelled JoinError instead of guessing at when
the runtime delivers a cancellation. The engine commands gain
kill_on_drop so an abort landing mid-pull does not orphan the subprocess.

`notify_waiters` stored no permit, so a 401 raised while the select loop
body was running another arm found no registered waiter and was dropped -
the flag then surfaced at the next session start, which is the one thing
moving the read inside the loop was meant to avoid. `notify_one` keeps
the permit. Clearing the flag after the send also erased any raise that
landed during it, so the lower now happens first and re-raises if the
send fails.

The stage timeouts covered TCP, TLS, the HTTP/1 handshake and the request
head - every stage except the one a sleeping laptop actually stalls in.
An idle deadline on the body bounds that without capping a legitimate
multi-gigabyte layer, since a link moving bytes at all keeps resetting
it.

The Status test that came with the reporting path built a DeviceFrame by
hand and asserted serde emitted its fields, so reverting the whole branch
to a bare warn! left it green. It now drives handle_host_frame, which
took the engine as a parameter to make that reachable. tokio's `sync`
feature is declared rather than borrowed from hyper's feature unification.
Both tests whose subject is "this must not hang forever" had no bound of
their own, so removing the fix under test hung the suite instead of
failing it. A mutation sweep caught it: gutting the session guard's Drop
and unwiring the body wrapper each produced a 180s timeout rather than a
named assertion failure. In CI that reads as flaky infrastructure and gets
retried, which is the opposite of what a regression should provoke.

The body wrapper could not be covered under a paused clock at all.
Unwired there is no timer left inside the body, and tokio's auto-advance
does not fire for an outer `timeout` when the inner future parks without
registering a waker - so the outer bound never came due and the test hung
anyway. The idle deadline is therefore short under test and the tests run
on the real clock, with the shipped 60s value asserted separately so the
override cannot hide a typo in the value that actually ships.

Signed-off-by: Javier Tia <javier@peridio.com>
git-subtree-dir: agent
git-subtree-mainline: 038c185
git-subtree-split: a93b392
Fills in the template with the extension that until now existed only
under avocado-os/extensions. That location is going away as avocado-os
reduces to a README, and it was also the reason this extension has never
reached a feed: publishing runs from an ext-* repo's own release
workflow, and this extension had no repo to run one from.

The crate arrives in the previous commit with its history intact rather
than as a flat copy, so `git log agent/` still explains why the code
looks the way it does.

Three things differ from the in-tree version, each for a reason:

The triple-resolution loop enumerates candidates and refuses an
ambiguous match instead of taking the first. It also skips the SDK's own
nativesdk triple, without which x86_64 resolves to two candidates and
refuses - the in-tree version picks the right one only because
"avocado-" happens to sort ahead of "avocadosdk-".

supported_targets names qemux86-64 and imx93-frdm rather than '*'. The
wildcard claimed every target in the platform on the evidence of one,
and the feed carries no repo at all for several machines it covered.

The SDK image is release-scoped from the environment, matching the
template. The in-tree version appended the channel, which resolves to a
tag that does not exist for every release except 2024.

Verified end to end: sdk install, ext install and ext build all succeed
for qemux86-64 from a clean clone, producing an x86-64 binary from
resolved-target x86_64-avocado-linux-gnu.

Signed-off-by: Javier Tia <javier@peridio.com>
@jetm
jetm merged commit 9e85059 into main Sep 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants