feat(update): let every host binary report its version, and refuse skew

The updater is component-driven: it compares the daemon and agent versions and
acts only when they differ, so a host whose individual binaries disagree looks
healthy. Carina ran a hand-installed archie-messaging 1.35.0 against a 1.30.0
state store and crash-looped on an RPC the older store does not serve, while
the updater reported "no approved component changes; nothing to install".

The reason a comparison was impossible: three of the six host binaries carried
no version at all. archie-ui, archie-messaging and archie-playbooks did not link
internal/app/archied, so the release ldflags never reached them; the gateway and
state store linked the variable but exposed no flag. Only archied could say what
it was.

- internal/buildinfo carries Version, stamped by all three build sites: the
  zip, install.sh, and the updater itself.
- Every host binary answers -version ("<name> <version>"). archied's existing
  two-line output is unchanged, because something parses it.
- archie-update-install reads each installed binary before it can report
  "nothing to install" and refuses, naming every binary that disagrees with the
  daemon's version; after an install it verifies the same set against the
  release it just installed, so a binary the release did not rebuild is skew
  rather than success.
- TestDistZipShipsEveryHostCommand pins stamping across the three build sites
  and requires each cmd/ to report, so a seventh command cannot arrive unstamped.
This commit is contained in:
sam committed 2026-09-22 14:52:18 +10:00
1 parent 3902b7ecbc
commit 70ea9b2a44
10 files changed
+197 -7

No files matched your search

+41
View File
@@ -117,7 +117,38 @@ if [ -n "$RT_TARGET" ] && [ "$RT_TARGET" != "$PREV_RT" ]; then
components="${components:+$components,}agent"
fi
# Per-binary skew is a different question from the unit set, and the one the
# updater could not answer (archie-core-k94o): it is component-driven, so a host
# whose individual binaries disagree -- a hand-installed outlier beside an
# otherwise current install -- looks healthy, because "no approved component
# changes" short-circuits before any binary is read. Ask every installed binary
# what it is and refuse, named, rather than reporting the install current.
verify_installed_versions() {
reference="$1"
problems=""
for cmd in $GATEWAY_BINARIES; do
[ -f "$BIN_DIR/$cmd" ] || continue
reported="$("$BIN_DIR/$cmd" -version 2>/dev/null | awk -v want="$cmd" '$1 == want { print $2; exit }')"
[ -n "$reported" ] || reported="unknown"
if [ "$reported" != "$reference" ]; then
problems="${problems:+$problems }$cmd=$reported"
fi
done
if [ -n "$problems" ]; then
echo "refusing: installed binaries disagree with $reference: $problems" >&2
echo "each host binary must report the release it was built from; reinstall the outliers from archied/v$reference, or approve an update that rebuilds them" >&2
return 1
fi
}
if [ -z "$components" ]; then
reference="$PREV_GW"
if [ -z "$reference" ]; then
reference="$("$BIN_DIR/archied" -version 2>/dev/null | awk '$1 == "archied" { print $2; exit }')"
fi
if [ -n "$reference" ] && ! verify_installed_versions "$reference"; then
exit 1
fi
echo '==> no approved component changes; nothing to install'
echo 'ARCHIE_UPDATE_RESULT {"previous":{},"installed":{},"components":[],"restart_requested":false}'
exit 0
@@ -243,6 +274,10 @@ if [[ ",$components," == *,daemon,* ]]; then
ldflags="-X github.com/samcharles93/archie-core/internal/app/archied.gatewayVersion=$GW"
ldflags="$ldflags -X github.com/samcharles93/archie-core/internal/app/archied.runtimeVersion=$RT"
ldflags="$ldflags -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary"
# The updater is a build site too: without this stamp its own outputs would
# report "dev" and fail the skew check it just installed.
ldflags="$ldflags -X github.com/samcharles93/archie-core/internal/buildinfo.Version=$GW"
ldflags="$ldflags -X github.com/samcharles93/archie-core/internal/buildinfo.Runtime=$RT"
for cmd in $GATEWAY_BINARIES; do
[ -d "./cmd/$cmd" ] || continue
echo "==> building $cmd $GW"
@@ -264,6 +299,12 @@ if [[ ",$components," == *,daemon,* ]]; then
for cmd in $built; do
install -m755 "$tmp/$cmd" "$BIN_DIR/$cmd"
done
# Every installed binary must now report the release just installed; a binary
# this release did not rebuild is skew, not success.
if ! verify_installed_versions "$GW"; then
exit 1
fi
fi
if [[ ",$components," == *,agent,* ]]; then
# Independent versioning: the agent tag usually points at a different