Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(release): close the deep-review fix wave for image publishing
Jose Ramirez819320f02439
diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.ymlindex 77d156aeb..abbf4980d 100644--- a/.github/workflows/build-publish.yml+++ b/.github/workflows/build-publish.yml@@ -10,8 +10,15 @@ name: Build & Publish# build_all=true rebuilds the whole matrix (use this for the first publish, or# to repopulate ghcr).#-# Every image is built multi-arch (amd64 + arm64). Each arch is built-# natively — no QEMU — as its own `build-push` matrix leg on a+# Every image is built multi-arch (amd64 + arm64), not amd64-only: minikube+# pulls these images directly onto arm64 hardware (Apple Silicon laptops), so+# any image minikube can reach needs an arm64 leg, and building the whole+# list uniformly avoids maintaining a separate opt-out list. Three published+# images -- mcp-host-desktop, clerum-workflow-base, playwright-server -- are+# not minikube-deployed and could drop the arm64 leg later if runner cost+# matters; not done here, since it would only save three legs and would also+# require the visibility guard to stop asserting arm64 for those three. Each+# arch is built natively — no QEMU — as its own `build-push` matrix leg on a# runner that matches (ubuntu-latest for amd64, ubuntu-24.04-arm for arm64),# pushed by digest, then the `merge` job combines the two digests into one# manifest list per image and pushes the sha-<7> and latest tags.diff --git a/.github/workflows/release-images.yml b/.github/workflows/release-images.ymlindex b1448cad4..7691e6e24 100644--- a/.github/workflows/release-images.yml+++ b/.github/workflows/release-images.yml@@ -2,6 +2,12 @@ name: Release images# Promotes dev-proven digests to a release tag. Never rebuilds -- prod promotes# what dev proved, per the rule build-publish.yml states in its own header.+#+# Prerequisite: no image carries an org.opencontainers.image.revision+# annotation until build-publish.yml has run at least once with+# build_all=true on dev (that's what the merge step writes it from). Until+# that first full-matrix run happens, this workflow will correctly refuse+# every image rather than promote one it cannot verify.on:push:tags: ['v*']diff --git a/deploy/overlays/minikube/kustomization.yaml b/deploy/overlays/minikube/kustomization.yamlindex cebf511c0..d6c431aad 100644--- a/deploy/overlays/minikube/kustomization.yaml+++ b/deploy/overlays/minikube/kustomization.yaml@@ -38,6 +38,8 @@ configurations:# Build local images with `eval $(minikube docker-env) && docker build -t# clerum/<svc>:test ./<svc>`. To roll a new local tag, change `newTag: test`# below in ONE place and re-render with `kubectl kustomize`.+# Every entry below must have a matching row in deploy/images.json --+# scripts/tests/test-images-manifest.sh enforces it.images:- name: clerum/channel-readernewTag: testdiff --git a/scripts/minikube/build-images.sh b/scripts/minikube/build-images.shindex 6c0180bb4..548c3808a 100755--- a/scripts/minikube/build-images.sh+++ b/scripts/minikube/build-images.sh@@ -252,7 +252,9 @@ elselog "Skipping docker-env; multi-node profiles use host builds plus 'minikube image load'"fi-# All images built in this session+# All images built in this session. Every entry here must have a matching+# row in deploy/images.json (via localRef()) -- scripts/tests/test-images-+# manifest.sh enforces it.ALL_IMAGES=("clerum/host-context-controller:test""clerum/workflow-recipes:test"diff --git a/scripts/release/images-manifest.mjs b/scripts/release/images-manifest.mjsindex 5b1ccbb1d..2bbb99785 100644--- a/scripts/release/images-manifest.mjs+++ b/scripts/release/images-manifest.mjs@@ -16,7 +16,15 @@ const MANIFEST_PATH = 'deploy/images.json'function load() {const raw = fs.readFileSync(path.join(ROOT, MANIFEST_PATH), 'utf8')- const parsed = JSON.parse(raw)+ let parsed+ try {+ parsed = JSON.parse(raw)+ } catch (error) {+ // Match every other failure in this function: a `deploy/images.json:`+ // prefix so a broken manifest names itself instead of surfacing a bare+ // SyntaxError with no file attached.+ throw new Error(`${MANIFEST_PATH}: invalid JSON -- ${error.message}`)+ }if (!Array.isArray(parsed.images)) {throw new Error(`${MANIFEST_PATH} must contain an "images" array`)}@@ -34,6 +42,21 @@ function load() {`from published && deployed_to_minikube and must not be written down`)}+ // An empty source_paths silently disabled resolve-release-images.mjs's+ // drift check: `(i.source_paths||[]).join(',')` produces '' for a missing+ // array, and the resolver's `if (sourcePaths)` then treats '' as "no+ // check requested" instead of "nothing to check", so the release gate+ // exits 0 without ever diffing. Reject it here, at the source, rather+ // than relying on every consumer to notice the gap on its own.+ if (+ image.published &&+ (!Array.isArray(image.source_paths) || image.source_paths.length === 0)+ ) {+ throw new Error(+ `${MANIFEST_PATH}: ${image.name} is published but has no source_paths -- the release gate ` ++ `would silently skip its drift check`+ )+ }}return parsed.images}diff --git a/scripts/release/promote-release-images.sh b/scripts/release/promote-release-images.shindex 43660e162..1e51760c3 100755--- a/scripts/release/promote-release-images.sh+++ b/scripts/release/promote-release-images.sh@@ -13,10 +13,9 @@ REGISTRY="ghcr.io/evenfire-ai"DRY_RUN="${DRY_RUN:-true}"RELEASE_REF="${RELEASE_REF:?RELEASE_REF is required}"VERSION="${RELEASE_REF#v}"-# The tag that lands must carry the same "v" the consuming kustomize-# component and the operator recovery docs pin (newTag: v0.6.0,-# MINIKUBE_IMAGE_TAG=v0.6.1) -- promoting to a bare :0.6.0 would produce a tag-# nothing downstream ever pulls.+# The tag that lands must carry a "v" prefix -- the consuming workstream pins+# a v-prefixed image tag downstream, so promoting to a bare :0.6.0 would+# produce a tag nothing ever pulls.TAG="v${VERSION}"TAG_SHA="$(git rev-parse "$RELEASE_REF^{commit}")"@@ -64,7 +63,15 @@ for row in "${IMAGES[@]}"; do| node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const m=JSON.parse(s).manifests||[];console.log(m.map(x=>x.platform?.architecture).filter(a=>a&&a!=="unknown").sort().join(","))})')"- if [ "$platforms" != "amd64,arm64" ]; then+ # Subset match, not exact equality against "amd64,arm64": check-image-+ # visibility.mjs's guard already treats a third platform as still+ # multi-arch (it checks .includes for each of amd64/arm64), and an index+ # with a third platform passing that guard but failing this one is exactly+ # the kind of drift these two guards must not have between them.+ has_amd64=false; has_arm64=false+ case ",$platforms," in *,amd64,*) has_amd64=true ;; esac+ case ",$platforms," in *,arm64,*) has_arm64=true ;; esac+ if [ "$has_amd64" != true ] || [ "$has_arm64" != true ]; thenecho "::error::$name@$digest is [$platforms], expected amd64,arm64"failed=1; continuefidiff --git a/scripts/release/resolve-release-images.mjs b/scripts/release/resolve-release-images.mjsindex c4cf4d444..12c9ecc90 100644--- a/scripts/release/resolve-release-images.mjs+++ b/scripts/release/resolve-release-images.mjs@@ -21,23 +21,13 @@// manifest list, and a per-leg `labels:` baked into each platform's image// config. The index read is one flat lookup with no --platform to get wrong// (`crane config --platform linux/amd64` would break if that leg's manifest-// were ever the one missing while another platform's was present). Verified-// against a real docker-buildx-built multi-arch index (amd64 + arm64, pushed-// by digest, merged with `imagetools create --annotation index:...`, exactly-// as build-publish.yml does it) during Task 4 development: `crane manifest-// <ref> | jq .annotations` and `crane config --platform linux/amd64 <ref> |-// jq .config.Labels` both returned the same revision, confirming either read-// works against the real thing crane is stubbed to imitate here.+// were ever the one missing while another platform's was present).import { execFileSync } from 'node:child_process'import process from 'node:process'+import { argValue } from './release-coordinates.mjs'const REGISTRY = 'ghcr.io/evenfire-ai'-function argValue(name) {- const index = process.argv.indexOf(name)- return index >= 0 ? process.argv[index + 1] : ''-}-function die(message) {console.error(`::error::${message}`)process.exit(1)@@ -83,11 +73,36 @@ if (!revision) {try {sh('git', ['merge-base', '--is-ancestor', revision, tagSha])} catch {+ // Not-an-ancestor covers two different situations, and only one of them is+ // "this image is stale": revision could be a DESCENDANT of tagSha (:latest+ // raced ahead on dev after tagSha was already tagged -- no merge fixes an+ // already-tagged historical commit into descending from a later one), or+ // the two commits could share no ancestry at all (diverged history, e.g. a+ // hotfix cut from an older base while dev moved on). Run the reverse check+ // to tell them apart instead of assuming staleness in both.+ let revisionIsDescendant = false+ try {+ sh('git', ['merge-base', '--is-ancestor', tagSha, revision])+ revisionIsDescendant = true+ } catch {+ // Neither is an ancestor of the other -- diverged history.+ }++ if (revisionIsDescendant) {+ die(+ `${image}: the published image was built from ${revision}, which comes AFTER the release ` ++ `commit ${tagSha} (it descends from it), not before -- :latest moved ahead on dev after ` ++ `${tagSha} was already tagged. This is not a stale image and merging will not help, since ` ++ `${tagSha} is fixed history now. Either cut the release tag from a commit that already ` ++ `includes ${revision}, or wait for a fresh dev-proven build whose revision predates ${tagSha}.`+ )+ }+die(- `${image}: the published image was built from ${revision}, which is not an ancestor of the ` +- `release commit ${tagSha} -- that image predates this release. :latest tracks dev, so re-running ` +- `build-publish would only move it further forward, not fix this. Merge dev into main so ` +- `${tagSha} descends from ${revision}, then cut the release tag again.`+ `${image}: the published image was built from ${revision}, which shares no ancestry with the ` ++ `release commit ${tagSha} -- they are on diverged history, so neither descends from the other. ` ++ `Re-publish the image from a commit that is actually an ancestor of ${tagSha}, then cut the ` ++ `release tag again.`)}diff --git a/scripts/tests/test-images-manifest.sh b/scripts/tests/test-images-manifest.shindex 8b7c68c45..120b752c7 100755--- a/scripts/tests/test-images-manifest.sh+++ b/scripts/tests/test-images-manifest.sh@@ -117,6 +117,51 @@ assert_pull_in_ghcr_mode_is_derived_not_stored() {fi}+# A published image with no source_paths let resolve-release-images.mjs's+# drift check silently no-op: promote-release-images.sh builds its+# --source-paths argument via `(i.source_paths||[]).join(',')`, which+# produces '' for a missing (or empty) array, and the resolver's+# `if (sourcePaths)` then reads '' as "no check requested" instead of+# "nothing to check" -- the release gate prints a digest and exits 0 across a+# window with a real diff, never complaining. Closed at the source here+# rather than relying on that one consumer to notice the gap.+#+# The real images-manifest.mjs is copied (not symlinked) into a throwaway+# tree, same reasoning as test-promote-release-images.sh's make_repo: it+# resolves deploy/images.json relative to its OWN file location via+# import.meta.url, which Node follows through a symlink back to this repo's+# real manifest -- only a real copy next to a throwaway deploy/images.json+# reads the throwaway one.+assert_a_published_image_with_no_source_paths_is_rejected() {+ local d; d="$(mktemp -d)"+ mkdir -p "$d/scripts/release" "$d/deploy"+ cp "$REPO_ROOT/scripts/release/images-manifest.mjs" "$d/scripts/release/"+ cat > "$d/deploy/images.json" <<'JSON'+{+ "images": [+ {+ "name": "widget",+ "path": "widget",+ "published": true,+ "deployed_to_minikube": false+ }+ ]+}+JSON+ local out rc+ out="$( cd "$d" && node -e '+ import("./scripts/release/images-manifest.mjs").catch(err => {+ console.log(err.message)+ process.exit(1)+ })' 2>&1 )" && rc=0 || rc=1+ if [ "$rc" -ne 0 ] && grep -qi "source_paths" <<< "$out"; then+ pass "a published image with no source_paths is rejected at load time"+ else+ fail "expected a named failure about missing source_paths; got rc=$rc out='$out'"+ fi+ rm -rf "$d"+}+assert_unpublished_images_are_exactly_the_known_three() {local gotgot="$(node -e '@@ -468,6 +513,7 @@ assert_manifest_parses_and_is_nonemptyassert_every_published_image_has_a_build_matrix_entryassert_every_local_image_maps_to_exactly_one_rowassert_pull_in_ghcr_mode_is_derived_not_stored+assert_a_published_image_with_no_source_paths_is_rejectedassert_unpublished_images_are_exactly_the_known_threeassert_matrix_fields_match_manifestassert_every_matrix_image_has_a_manifest_rowdiff --git a/scripts/tests/test-promote-release-images.sh b/scripts/tests/test-promote-release-images.shindex 4f8af2215..97f55b175 100755--- a/scripts/tests/test-promote-release-images.sh+++ b/scripts/tests/test-promote-release-images.sh@@ -26,6 +26,8 @@ make_repo() {cp "$REPO_ROOT/scripts/release/images-manifest.mjs" "$d/scripts/release/"cp "$REPO_ROOT/scripts/release/resolve-release-images.mjs" "$d/scripts/release/"cp "$REPO_ROOT/scripts/release/promote-release-images.sh" "$d/scripts/release/"+ # resolve-release-images.mjs imports argValue from here.+ cp "$REPO_ROOT/scripts/release/release-coordinates.mjs" "$d/scripts/release/"cat > "$d/deploy/images.json" <<'JSON'{"images": [@@ -154,11 +156,11 @@ assert_the_real_promotion_copies_to_the_v_prefixed_tag() {( cd "$d" && PATH="$d/bin:$PATH" DRY_RUN=false RELEASE_REF=v0.1.0 \bash scripts/release/promote-release-images.sh >/dev/null 2>&1 )local log; log="$(cat "$d/copy-log" 2>/dev/null || echo '')"- # The consuming kustomize component and the operator recovery docs pin- # newTag: v0.6.0 / MINIKUBE_IMAGE_TAG=v0.6.1 -- WITH the v. This checks the- # actual `crane copy` destination argument, not just an echo string, since- # the echo and the real copy target were two separate lines that could- # drift from each other.+ # The tag that lands must carry a "v" prefix -- the consuming workstream+ # pins a v-prefixed image tag downstream. This checks the actual `crane+ # copy` destination argument, not just an echo string, since the echo and+ # the real copy target were two separate lines that could drift from each+ # other.if grep -q 'ghcr.io/evenfire-ai/widget:v0.1.0$' <<< "$log" && grep -q 'ghcr.io/evenfire-ai/widget:stable$' <<< "$log"; thenpass "a real promotion copies to the v-prefixed version tag and moves :stable for a strict release"elsediff --git a/scripts/tests/test-resolve-release-images.sh b/scripts/tests/test-resolve-release-images.shindex 5ea6d002a..1887c2995 100755--- a/scripts/tests/test-resolve-release-images.sh+++ b/scripts/tests/test-resolve-release-images.sh@@ -77,17 +77,47 @@ assert_a_non_ancestor_revision_is_rejected() {rm -rf "$d"}+assert_a_descendant_revision_is_rejected_with_accurate_advice() {+ local d; d="$(mktemp -d)"; make_repo "$d"+ local new; new="$( cd "$d" && git rev-parse HEAD )"+ local old; old="$( cd "$d" && git rev-parse HEAD~1 )"+ # revision (HEAD, the NEWER commit) was built AFTER the release commit+ # (HEAD~1, the OLDER one): :latest raced ahead on dev while an older+ # commit got tagged for release -- e.g. a hotfix cut from an older base.+ # The generic "predates this release, merge dev into main" advice is+ # backwards here: an already-tagged historical commit cannot be merged+ # into descending from a later one. Distinguished from+ # assert_a_non_ancestor_revision_is_rejected above (which uses an+ # unrelated bogus SHA, i.e. diverged history) by using a revision that+ # IS related to tagSha, just on the wrong side of it.+ make_stub "$d" "sha256:abc" "$new"+ local out rc+ out="$( cd "$d" && PATH="$d/bin:$PATH" node "$REPO_ROOT/scripts/release/resolve-release-images.mjs" \+ --image control-api --source-paths 'control-api/**' --tag-sha "$old" 2>&1 )" && rc=0 || rc=1+ if [ "$rc" -ne 0 ] && grep -qi "AFTER the release" <<< "$out" && ! grep -q "Merge dev into main" <<< "$out"; then+ pass "a revision that descends from the release commit is rejected with accurate, non-backwards advice"+ else+ fail "expected non-backwards descendant advice (\"AFTER the release\", no \"Merge dev into main\"); got rc=$rc out='$out'"+ fi+ rm -rf "$d"+}+assert_a_source_change_after_the_revision_is_rejected() {local d; d="$(mktemp -d)"; make_repo "$d"local old; old="$( cd "$d" && git rev-parse HEAD~1 )"make_stub "$d" "sha256:abc" "$old"# control-api/** DID change between $old and HEAD, so promoting $old would- # ship an image that predates the release's own source.- if ( cd "$d" && PATH="$d/bin:$PATH" node "$REPO_ROOT/scripts/release/resolve-release-images.mjs" \- --image control-api --source-paths 'control-api/**' --tag-sha HEAD >/dev/null 2>&1 ); then- fail "a source change after the published image was accepted"- else+ # ship an image that predates the release's own source. Checked by message,+ # not rc alone, matching its two siblings above (the ancestor guard and the+ # missing-annotation guard): an rc-only check can't tell this specific+ # guard firing apart from any other failure that happens to exit nonzero.+ local out rc+ out="$( cd "$d" && PATH="$d/bin:$PATH" node "$REPO_ROOT/scripts/release/resolve-release-images.mjs" \+ --image control-api --source-paths 'control-api/**' --tag-sha HEAD 2>&1 )" && rc=0 || rc=1+ if [ "$rc" -ne 0 ] && grep -qi "source changed" <<< "$out"; thenpass "a source change after the published image is rejected"+ else+ fail "expected a named failure about the source changing after the published image; got rc=$rc out='$out'"firm -rf "$d"}@@ -185,6 +215,7 @@ assert_every_defined_case_is_invoked() {assert_a_revision_that_is_an_ancestor_resolvesassert_a_non_ancestor_revision_is_rejected+assert_a_descendant_revision_is_rejected_with_accurate_adviceassert_a_source_change_after_the_revision_is_rejectedassert_a_missing_revision_annotation_fails_loudlyassert_the_digest_is_resolved_once_and_reused