Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

feat(release): add the ghcr component pin as a release coordinate

Jose Ramirez75f4bc0ef9d1
diff --git a/scripts/release/release-coordinates.mjs b/scripts/release/release-coordinates.mjs
index d0baf787b..6a8fdb721 100644
--- a/scripts/release/release-coordinates.mjs
+++ b/scripts/release/release-coordinates.mjs
@@ -8,11 +8,14 @@
// equals - must equal the release version (build inputs, declarations)
// floor - a compatibility floor; must be <= the version, moves only on request
// counter - a per-service counter; must equal ITS OWN package.json, not the version
-// pointer - names an artifact; equality here, plus existence checking once a
-// release-images.yml workflow exists (it does not exist in this repo yet)
+// pointer - names an artifact; equality ONLY, never existence
//
-// A future workstream would append the ghcr component pointer row. Do not add
-// it before deploy/components/ghcr-images/kustomization.yaml exists.
+// The ghcr component pointer row is the eighth coordinate, added by the image-
+// consumption workstream once deploy/components/ghcr-images/kustomization.yaml
+// existed. Its assertion is deliberately NOT "and the artifact exists": the
+// v<version> images are created by release-images.yml ON THE TAG, so they
+// cannot pre-exist when the release-prep PR is checked. Existence is the split
+// checker's other half.
import fs from 'node:fs'
import path from 'node:path'
@@ -62,6 +65,26 @@ export function parseManifest(raw) {
return JSON.parse(normalized)
}
+const GHCR_COMPONENT = 'deploy/components/ghcr-images/kustomization.yaml'
+
+// One `newTag:` line of an images[] row. [ \t] rather than \s on purpose: \s
+// matches newlines, so `^\s+` can begin on a blank line and swallow the line
+// separator into the match.
+const GHCR_NEW_TAG_RE = /^([ \t]*newTag:[ \t]*)(\S+)[ \t]*$/gm
+
+function readGhcrComponent(root) {
+ const abs = path.join(root, GHCR_COMPONENT)
+ try {
+ return fs.readFileSync(abs, 'utf8')
+ } catch (error) {
+ throw new Error(
+ `PARSE_ERROR: cannot read the ghcr release pin at ${GHCR_COMPONENT} ` +
+ `(${error.code ?? error.message}). That file is a release coordinate; ` +
+ `it must exist in the tree being cut or checked.`
+ )
+ }
+}
+
function manifestField(root, field) {
const raw = fs.readFileSync(path.join(root, 'external-rest-api/src/releaseManifest.ts'), 'utf8')
const manifest = parseManifest(raw)
@@ -132,6 +155,41 @@ export const COORDINATES = [
read: root => manifestField(root, 'rpcProxyVersion'),
writtenBy: 'update-desktop-release-manifest.mjs',
},
+ {
+ name: 'deploy/components/ghcr-images newTag',
+ assert: 'pointer',
+ // Reads EVERY newTag, not just the first: a half-applied rewrite leaves
+ // mixed tags, and the puller would then fetch two different releases into
+ // one cluster. Returning the joined distinct set makes that state
+ // unmistakable in the failure message instead of invisible. Zero rows join
+ // to '', which the checker reports as (empty) and rejects -- a guard that
+ // scanned nothing must fail, not agree.
+ read: root => {
+ const raw = readGhcrComponent(root)
+ const tags = [...raw.matchAll(GHCR_NEW_TAG_RE)].map(m => m[2])
+ return [...new Set(tags)].join('/')
+ },
+ write: (root, version) => {
+ const raw = readGhcrComponent(root)
+ // Every row, anchored per line. A `latest`/`stable` value would also be
+ // rewritten, which is correct: the committed component must never carry
+ // a moving tag, and MINIKUBE_IMAGE_TAG is the render-time lever instead.
+ let rewritten = 0
+ const next = raw.replace(GHCR_NEW_TAG_RE, (_match, prefix) => {
+ rewritten += 1
+ return `${prefix}v${version}`
+ })
+ // A writer that wrote nothing is a failed cut, not a no-op. Saying so
+ // here beats leaving the stale pin for the checker to find on the PR.
+ if (rewritten === 0) {
+ throw new Error(
+ `PARSE_ERROR: ${GHCR_COMPONENT} has no newTag: rows matching ` +
+ `${GHCR_NEW_TAG_RE}, so the release pin could not be written`
+ )
+ }
+ fs.writeFileSync(path.join(root, GHCR_COMPONENT), next)
+ },
+ },
]
export function readCounterPackage(root, rel) {
diff --git a/scripts/release/validate-release-tag.mjs b/scripts/release/validate-release-tag.mjs
index 4bee820ed..c417fe369 100644
--- a/scripts/release/validate-release-tag.mjs
+++ b/scripts/release/validate-release-tag.mjs
@@ -3,9 +3,9 @@
// runs locally and on the release-prep PR, before any tag exists.
//
// It deliberately does NOT check that the artifacts exist. The v<version>
-// images would be built by a future release-images.yml workflow on the tag
-// (not yet added to this repo), so they cannot pre-exist here. Existence
-// checking is that future workflow's job, not this one's.
+// images are created by .github/workflows/release-images.yml ON THE TAG, so
+// they cannot pre-exist here -- asserting existence would make every
+// release-prep PR red. Existence is that workflow's half of the split checker.
//
// node scripts/release/validate-release-tag.mjs --version 0.6.0
import process from 'node:process'
@@ -32,10 +32,10 @@ const failures = []
for (const coordinate of COORDINATES) {
const actual = coordinate.read(ROOT)
- // A switch with a default is deliberate: an unrecognized `assert` kind
- // (e.g. a `pointer` row added before its check is implemented) must fail
- // loudly, naming the coordinate and the kind, rather than silently falling
- // through every case the way independent `if`s with no `else` would.
+ // A switch with a default is deliberate: an unrecognized `assert` kind (a
+ // new row landing before its check is implemented) must fail loudly, naming
+ // the coordinate and the kind, rather than silently falling through every
+ // case the way independent `if`s with no `else` would.
switch (coordinate.assert) {
case 'equals': {
if (actual !== version) {
@@ -70,6 +70,26 @@ for (const coordinate of COORDINATES) {
break
}
+ case 'pointer': {
+ // The pin is v-prefixed; the release version is not. `read` returns the
+ // DISTINCT set joined by '/', so a half-applied rewrite ("v0.6.0/v0.5.0")
+ // fails here rather than passing on whichever row happened to be first.
+ //
+ // Equality only. The v<version> images are created by release-images.yml
+ // ON THE TAG, so they cannot pre-exist when this runs on the release-prep
+ // PR; asserting existence here would make every release-prep PR red.
+ const expected = `v${version}`
+ if (actual !== expected) {
+ failures.push(
+ `${coordinate.name}=${actual || '(empty)'}, expected ${expected}` +
+ (actual.includes('/')
+ ? ' (the component carries MIXED tags, so a previous rewrite was half-applied)'
+ : '')
+ )
+ }
+ break
+ }
+
default: {
failures.push(
`${coordinate.name} has assert kind "${coordinate.assert}", which this checker does not ` +
diff --git a/scripts/tests/test-release-coordinates.sh b/scripts/tests/test-release-coordinates.sh
index c4b90aa21..b2fc9a686 100755
--- a/scripts/tests/test-release-coordinates.sh
+++ b/scripts/tests/test-release-coordinates.sh
@@ -15,6 +15,40 @@ REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
pass() { echo "PASS: $1"; }
fail() { echo "FAIL: $1"; FAIL=1; }
+# Write the ghcr pointer component the eighth coordinate reads.
+# Usage: make_ghcr_component <dir> <tag> [secondRowTag]
+# Two rows, because the component in the real tree has one per published image
+# and the coordinate must handle ALL of them. The optional second tag builds a
+# deliberately half-rewritten component; it defaults to the first, which is the
+# only coherent state.
+make_ghcr_component() {
+ local d=$1 tag=$2 tag2=${3:-$2}
+ mkdir -p "$d/deploy/components/ghcr-images"
+ cat > "$d/deploy/components/ghcr-images/kustomization.yaml" <<EOF
+apiVersion: kustomize.config.k8s.io/v1alpha1
+kind: Component
+
+configurations:
+ - imagetags.yaml
+
+images:
+ - name: clerum/control-api
+ newName: ghcr.io/evenfire-ai/control-api
+ newTag: $tag
+ - name: clerum/control-ui
+ newName: ghcr.io/evenfire-ai/control-ui
+ newTag: $tag2
+EOF
+}
+
+# The DISTINCT set of newTag values in the component, space separated. A
+# coherent component collapses to one value; a half-applied rewrite shows both,
+# which is the state that must never read as "the first one wins".
+component_tags() {
+ sed -n 's/^[[:space:]]*newTag:[[:space:]]*\([^[:space:]]*\)[[:space:]]*$/\1/p' \
+ "$1/deploy/components/ghcr-images/kustomization.yaml" | sort -u | tr '\n' ' '
+}
+
# Build a scratch repo with the given desktop/ers/rpc versions and manifest.
# Usage: make_fixture <dir> <desktopVersion> <ersVersion> <rpcVersion> \
# <manifestDesktop> <manifestMinimum> <manifestErs> <manifestRpc>
@@ -42,6 +76,12 @@ export const releaseManifest: ReleaseManifest = {
minimumDesktopVersion: '$mmin',
}
EOF
+ # The ghcr pin is a coordinate like any other, so every fixture carries one.
+ # Without it the checker's read would blow up on a missing file and every
+ # negative case below would "pass" on the crash instead of on the thing it
+ # claims to test. Pinned to v<desktopVersion> so a fixture that is coherent
+ # for the desktop coordinates is coherent for this one too.
+ make_ghcr_component "$d" "v$dv"
( cd "$d" && git init -q . && git add -A && git -c user.email=t@t -c user.name=t commit -qm init )
}
@@ -382,6 +422,8 @@ export const releaseManifestRENAMED: ReleaseManifest = {
minimumDesktopVersion: '0.1.252',
}
EOF
+ # Coherent ghcr pin: the ONLY disagreement in this tree must be the manifest.
+ make_ghcr_component "$d" v0.6.0
cp -R "$REPO_ROOT/scripts" "$d/scripts"
if ( cd "$d" && node scripts/release/validate-release-tag.mjs --version 0.6.0 >/dev/null 2>&1 ); then
@@ -429,6 +471,8 @@ export const releaseManifest: ReleaseManifest = {
minimumDesktopVersion: '9.9.9',
}
EOF
+ # Coherent ghcr pin: the ONLY disagreement in this tree must be the manifest.
+ make_ghcr_component "$d" v0.6.0
cp -R "$REPO_ROOT/scripts" "$d/scripts"
if ( cd "$d" && node scripts/release/validate-release-tag.mjs --version 0.6.0 >/dev/null 2>&1 ); then
@@ -521,12 +565,17 @@ assert_unhandled_assert_kind_fails_closed() {
make_fixture "$d" 0.6.0 0.1.60 0.1.51 0.6.0 0.1.252 0.1.60 0.1.51
cp -R "$REPO_ROOT/scripts" "$d/scripts"
- # Append an 8th coordinate whose assert kind ('pointer') the checker does
- # not implement, carrying a deliberately garbage value that would never
- # agree with anything. If an unrecognized assert kind falls through every
- # branch instead of failing closed, this coordinate is never actually
- # checked and the tree still reports success -- the exact bug this case
- # guards against.
+ # Append an extra coordinate whose assert kind the checker does not
+ # implement, carrying a deliberately garbage value that would never agree
+ # with anything. If an unrecognized assert kind falls through every branch
+ # instead of failing closed, this coordinate is never actually checked and
+ # the tree still reports success -- the exact bug this case guards against.
+ #
+ # The injected kind must be one the checker genuinely has no case for. This
+ # used to inject 'pointer', which worked only while 'pointer' was unimplemented;
+ # once the ghcr pin landed as a real pointer coordinate, that injection was
+ # caught by the pointer case (garbage != v0.6.0) and this case would have kept
+ # passing with the `default:` branch deleted.
node -e '
const fs = require("fs")
const p = process.argv[1]
@@ -536,8 +585,8 @@ assert_unhandled_assert_kind_fails_closed() {
s = s.replace(
marker,
"COORDINATES.push({\n" +
- " name: \"test-only-pointer-coordinate\",\n" +
- " assert: \"pointer\",\n" +
+ " name: \"test-only-unimplemented-kind-coordinate\",\n" +
+ " assert: \"no-such-assert-kind\",\n" +
" read: () => \"garbage-value-that-is-never-checked\",\n" +
"})\n\n" +
marker
@@ -546,13 +595,168 @@ assert_unhandled_assert_kind_fails_closed() {
' "$d/scripts/release/release-coordinates.mjs"
if ( cd "$d" && node scripts/release/validate-release-tag.mjs --version 0.6.0 >/dev/null 2>&1 ); then
- fail "validate-release-tag passed with an unhandled assert kind ('pointer') on a coordinate"
+ fail "validate-release-tag passed with an unhandled assert kind ('no-such-assert-kind') on a coordinate"
else
pass "validate-release-tag fails closed on an unhandled assert kind instead of skipping it silently"
fi
rm -rf "$d"
}
+# The pin must be a full coordinate, not a hand-bumped file. A release cut that
+# moves the desktop version and leaves the pin behind ships a v0.6.0 whose
+# desktop app reports 0.6.0 while minikube-setup pulls v0.5.0 images -- the
+# exact skew the one-writer rule exists to prevent.
+assert_prepare_release_writes_the_ghcr_pin() {
+ local d out rc; d="$(mktemp -d)"
+ make_fixture "$d" 0.5.0 0.1.60 0.1.51 0.5.0 0.1.252 0.1.60 0.1.51
+ make_ghcr_component "$d" v0.5.0
+ cp -R "$REPO_ROOT/scripts" "$d/scripts"
+ out="$( cd "$d" && node scripts/release/prepare-release.mjs \
+ --version 0.6.0 --release-id t 2>&1 )"; rc=$?
+ local got; got="$(component_tags "$d")"
+ if [ "$rc" -eq 0 ] && [ "$got" = "v0.6.0 " ]; then
+ pass "prepare-release.mjs writes the ghcr component pin"
+ else
+ fail "component tags after the cut were '${got}', expected 'v0.6.0 ' (rc=$rc out='$out')"
+ fi
+ rm -rf "$d"
+}
+
+# The pin is v-prefixed; the release version is not. Writing 0.6.0 into the
+# component would produce a tag that never exists.
+assert_the_pin_is_written_v_prefixed() {
+ local d; d="$(mktemp -d)"
+ make_fixture "$d" 0.5.0 0.1.60 0.1.51 0.5.0 0.1.252 0.1.60 0.1.51
+ make_ghcr_component "$d" v0.5.0
+ cp -R "$REPO_ROOT/scripts" "$d/scripts"
+ ( cd "$d" && node scripts/release/prepare-release.mjs \
+ --version 0.6.0 --release-id t >/dev/null 2>&1 )
+ local component="$d/deploy/components/ghcr-images/kustomization.yaml"
+ if grep -q 'newTag: v0.6.0' "$component" && ! grep -qE 'newTag: 0\.6\.0' "$component"; then
+ pass "the pin is written as v0.6.0, not 0.6.0"
+ else
+ fail "the written pin is not v-prefixed: $(component_tags "$d")"
+ fi
+ rm -rf "$d"
+}
+
+# EVERY row, not just the first. A rewrite that missed rows would produce a
+# component with mixed tags, and the puller would fetch two different releases.
+assert_every_component_row_is_rewritten() {
+ local d; d="$(mktemp -d)"
+ make_fixture "$d" 0.5.0 0.1.60 0.1.51 0.5.0 0.1.252 0.1.60 0.1.51
+ make_ghcr_component "$d" v0.5.0
+ cp -R "$REPO_ROOT/scripts" "$d/scripts"
+ ( cd "$d" && node scripts/release/prepare-release.mjs \
+ --version 0.6.0 --release-id t >/dev/null 2>&1 )
+ local count
+ count="$(grep -c 'newTag: v0.6.0' "$d/deploy/components/ghcr-images/kustomization.yaml")"
+ if [ "$count" = "2" ]; then
+ pass "every component row was rewritten, not just the first"
+ else
+ fail "only $count of 2 rows carry the new pin"
+ fi
+ rm -rf "$d"
+}
+
+assert_validate_release_tag_catches_a_stale_pin() {
+ local d out rc; d="$(mktemp -d)"
+ make_fixture "$d" 0.6.0 0.1.60 0.1.51 0.6.0 0.1.252 0.1.60 0.1.51
+ make_ghcr_component "$d" v0.5.0
+ cp -R "$REPO_ROOT/scripts" "$d/scripts"
+ out="$( cd "$d" && node scripts/release/validate-release-tag.mjs --version 0.6.0 2>&1 )"; rc=$?
+ if [ "$rc" -ne 0 ] && grep -q "ghcr" <<< "$out" && grep -q "v0.5.0" <<< "$out"; then
+ pass "the checker catches a stale ghcr pin, naming it"
+ else
+ fail "expected a failure naming the ghcr pin and v0.5.0; got rc=$rc out='$out'"
+ fi
+ rm -rf "$d"
+}
+
+# The checker must NOT reach the registry. The v<version> images are created by
+# release-images.yml ON THE TAG, so they cannot exist when the release-prep PR
+# is checked. Asserting existence here would make every release-prep PR red.
+assert_the_pointer_check_does_not_require_the_artifact_to_exist() {
+ local d out rc; d="$(mktemp -d)"
+ make_fixture "$d" 0.6.0 0.1.60 0.1.51 0.6.0 0.1.252 0.1.60 0.1.51
+ make_ghcr_component "$d" v0.6.0
+ cp -R "$REPO_ROOT/scripts" "$d/scripts"
+ # No network, no registry, no tag: a pure tree read must still pass.
+ out="$( cd "$d" && node scripts/release/validate-release-tag.mjs --version 0.6.0 2>&1 )"; rc=$?
+ if [ "$rc" -eq 0 ]; then
+ pass "the pointer check is a pure tree read; artifact existence is release-images.yml's half"
+ else
+ fail "the checker rejected an agreeing tree (rc=$rc): $out"
+ fi
+ rm -rf "$d"
+}
+
+# A component with mixed newTag values is not "the first one wins" -- it is a
+# half-applied write, and reading only the first would hide it.
+assert_a_mixed_tag_component_is_rejected() {
+ local d out rc; d="$(mktemp -d)"
+ make_fixture "$d" 0.6.0 0.1.60 0.1.51 0.6.0 0.1.252 0.1.60 0.1.51
+ # First row already bumped, second row left behind: the first-row read that
+ # this case exists to forbid would see v0.6.0 and pass.
+ make_ghcr_component "$d" v0.6.0 v0.5.0
+ cp -R "$REPO_ROOT/scripts" "$d/scripts"
+ out="$( cd "$d" && node scripts/release/validate-release-tag.mjs --version 0.6.0 2>&1 )"; rc=$?
+ if [ "$rc" -ne 0 ] && grep -q "MIXED" <<< "$out"; then
+ pass "a component with mixed newTag values is rejected"
+ else
+ fail "a half-rewritten component passed the checker (rc=$rc): $out"
+ fi
+ rm -rf "$d"
+}
+
+# Gut the component's images list: a file that still parses as a Component but
+# carries no pin at all.
+gut_ghcr_component() {
+ cat > "$1/deploy/components/ghcr-images/kustomization.yaml" <<'EOF'
+apiVersion: kustomize.config.k8s.io/v1alpha1
+kind: Component
+
+configurations:
+ - imagetags.yaml
+
+images: []
+EOF
+}
+
+# A writer that wrote nothing is a failed cut, not a no-op. Silently rewriting
+# zero rows would hand the operator a "prepared release 0.6.0" over a tree with
+# no pin in it at all.
+assert_prepare_release_fails_loudly_when_no_row_can_be_written() {
+ local d out rc; d="$(mktemp -d)"
+ make_fixture "$d" 0.5.0 0.1.60 0.1.51 0.5.0 0.1.252 0.1.60 0.1.51
+ gut_ghcr_component "$d"
+ cp -R "$REPO_ROOT/scripts" "$d/scripts"
+ out="$( cd "$d" && node scripts/release/prepare-release.mjs \
+ --version 0.6.0 --release-id t 2>&1 )"; rc=$?
+ if [ "$rc" -ne 0 ] && grep -q "ghcr-images/kustomization.yaml" <<< "$out"; then
+ pass "prepare-release fails loudly, naming the file, when no pin row can be written"
+ else
+ fail "a cut over a component with no pin rows reported rc=$rc: $out"
+ fi
+ rm -rf "$d"
+}
+
+# A guard that scanned zero rows is a broken guard, not a passing one. A
+# component whose images list was gutted must fail, not read as agreement.
+assert_a_component_with_no_rows_is_rejected() {
+ local d out rc; d="$(mktemp -d)"
+ make_fixture "$d" 0.6.0 0.1.60 0.1.51 0.6.0 0.1.252 0.1.60 0.1.51
+ gut_ghcr_component "$d"
+ cp -R "$REPO_ROOT/scripts" "$d/scripts"
+ out="$( cd "$d" && node scripts/release/validate-release-tag.mjs --version 0.6.0 2>&1 )"; rc=$?
+ if [ "$rc" -ne 0 ] && grep -q "empty" <<< "$out"; then
+ pass "a component carrying no newTag rows is rejected, not read as agreement"
+ else
+ fail "a component with zero newTag rows was accepted (rc=$rc): $out"
+ fi
+ rm -rf "$d"
+}
+
assert_every_coordinate_has_a_case() {
local declared cases
declared="$(node -e '
@@ -656,6 +860,14 @@ assert_counter_mismatch_is_rejected_by_the_checker
assert_unhandled_assert_kind_fails_closed
assert_floor_above_version_is_rejected_before_any_write
assert_a_half_cut_release_can_be_completed_by_rerunning
+assert_prepare_release_writes_the_ghcr_pin
+assert_the_pin_is_written_v_prefixed
+assert_every_component_row_is_rewritten
+assert_validate_release_tag_catches_a_stale_pin
+assert_the_pointer_check_does_not_require_the_artifact_to_exist
+assert_a_mixed_tag_component_is_rejected
+assert_prepare_release_fails_loudly_when_no_row_can_be_written
+assert_a_component_with_no_rows_is_rejected
assert_every_coordinate_has_a_case
assert_every_defined_case_is_invoked