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 release coordinate table, writer, and checker

Jose Ramirez5199eb23f8a8
diff --git a/scripts/release/prepare-release.mjs b/scripts/release/prepare-release.mjs
new file mode 100755
index 000000000..e6dd6d3cb
--- /dev/null
+++ b/scripts/release/prepare-release.mjs
@@ -0,0 +1,63 @@
+#!/usr/bin/env node
+// The one release-cut writer. Writes every coordinate in the table, then
+// delegates the manifest to update-desktop-release-manifest.mjs rather than
+// duplicating its renderer.
+//
+// node scripts/release/prepare-release.mjs --version 0.6.0 --release-id <id> \
+// [--minimum-desktop-version 0.6.0]
+import { execFileSync } from 'node:child_process'
+import process from 'node:process'
+import { COORDINATES, SEMVER_RE, compareVersions } from './release-coordinates.mjs'
+
+const ROOT = process.cwd()
+
+function argValue(name) {
+ const i = process.argv.indexOf(name)
+ return i >= 0 ? process.argv[i + 1] : ''
+}
+
+function die(message) {
+ console.error(message)
+ process.exit(1)
+}
+
+const version = argValue('--version')
+const releaseId = argValue('--release-id')
+const minimumDesktopVersion = argValue('--minimum-desktop-version')
+
+if (!SEMVER_RE.test(version)) {
+ die(`--version must be MAJOR.MINOR.PATCH, got: ${version || '(missing)'}`)
+}
+
+// releaseId is required, never defaulted. update-desktop-release-manifest.mjs
+// falls back to the string 'local', which would ship in a customer-facing
+// manifest if this script stayed silent.
+if (!releaseId) {
+ die('--release-id is required (it reaches a customer-facing manifest)')
+}
+
+if (minimumDesktopVersion && !SEMVER_RE.test(minimumDesktopVersion)) {
+ die(`--minimum-desktop-version must be MAJOR.MINOR.PATCH, got: ${minimumDesktopVersion}`)
+}
+
+const current = COORDINATES.find(c => c.name === 'desktop-app/package.json').read(ROOT)
+if (compareVersions(version, current) <= 0) {
+ die(`--version ${version} is not greater than the current desktop version ${current}`)
+}
+
+for (const coordinate of COORDINATES) {
+ // Rows without a write are owned by the delegated updater below.
+ coordinate.write?.(ROOT, version)
+}
+
+const manifestArgs = [
+ 'scripts/release/update-desktop-release-manifest.mjs',
+ '--release-id',
+ releaseId,
+]
+if (minimumDesktopVersion) {
+ manifestArgs.push('--minimum-desktop-version', minimumDesktopVersion)
+}
+execFileSync('node', manifestArgs, { cwd: ROOT, stdio: 'inherit' })
+
+console.log(`prepared release ${version}`)
diff --git a/scripts/release/release-coordinates.mjs b/scripts/release/release-coordinates.mjs
new file mode 100644
index 000000000..22cca1ae7
--- /dev/null
+++ b/scripts/release/release-coordinates.mjs
@@ -0,0 +1,132 @@
+#!/usr/bin/env node
+// The release coordinates: every place in the tree that must agree with the
+// release tag. One writer (prepare-release.mjs) and one checker
+// (validate-release-tag.mjs) both import this list, so a coordinate cannot be
+// written without being checked.
+//
+// The coordinates are NOT all the same kind of thing, which is why each row
+// carries its own assertion:
+// 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, existence checked by release-images.yml
+//
+// Workstream D appends the ghcr component pointer row. Do not add it before
+// deploy/components/ghcr-images/kustomization.yaml exists.
+import fs from 'node:fs'
+import path from 'node:path'
+
+export const SEMVER_RE = /^\d+\.\d+\.\d+$/
+
+export function compareVersions(a, b) {
+ const pa = a.split('.').map(Number)
+ const pb = b.split('.').map(Number)
+ for (let i = 0; i < 3; i += 1) {
+ if (pa[i] !== pb[i]) return pa[i] < pb[i] ? -1 : 1
+ }
+ return 0
+}
+
+function readJson(root, rel) {
+ return JSON.parse(fs.readFileSync(path.join(root, rel), 'utf8'))
+}
+
+function writeJson(root, rel, obj) {
+ fs.writeFileSync(path.join(root, rel), `${JSON.stringify(obj, null, 2)}\n`)
+}
+
+// Parses the `releaseManifest` export specifically, not just any object in
+// the file that happens to declare the same field names. A field-by-field
+// line regex over the whole file (the earlier approach here) would match the
+// FIRST line anywhere that looks like ` field: 'value'` -- including a
+// decoy object placed above the real export, or nothing at all if the export
+// were renamed, in which case a naive per-field regex silently returns ''
+// per field instead of failing loudly. Anchoring on the export statement and
+// parsing the whole object closes both holes at once. This is the same
+// parser update-desktop-release-manifest.mjs uses, imported from here so
+// there is exactly one implementation.
+export function parseManifest(raw) {
+ const match = raw.match(/export const releaseManifest: ReleaseManifest = (\{[\s\S]*?\n\})/)
+ if (!match) return null
+ const normalized = match[1]
+ .replace(/([{,]\s*)([a-zA-Z][a-zA-Z0-9]*):/g, '$1"$2":')
+ .replace(/'/g, '"')
+ .replace(/,\s*}/g, '}')
+ return JSON.parse(normalized)
+}
+
+function manifestField(root, field) {
+ const raw = fs.readFileSync(path.join(root, 'external-rest-api/src/releaseManifest.ts'), 'utf8')
+ const manifest = parseManifest(raw)
+ return manifest ? String(manifest[field] ?? '') : ''
+}
+
+// A row carries `write` only when it owns its own write. The manifest fields
+// are written by update-desktop-release-manifest.mjs, which prepare-release
+// delegates to rather than duplicating its renderer, so those rows declare
+// `writtenBy` instead. The writer skips any row without a `write`.
+export const COORDINATES = [
+ {
+ name: 'desktop-app/package.json',
+ assert: 'equals',
+ read: root => readJson(root, 'desktop-app/package.json').version,
+ write: (root, version) => {
+ const j = readJson(root, 'desktop-app/package.json')
+ j.version = version
+ writeJson(root, 'desktop-app/package.json', j)
+ },
+ },
+ {
+ name: 'desktop-app/package-lock.json',
+ assert: 'equals',
+ read: root => {
+ const j = readJson(root, 'desktop-app/package-lock.json')
+ // Both sites must agree; report a mismatch as an unmistakable value.
+ const rootVersion = j.version
+ const pkgVersion = j.packages?.['']?.version
+ return rootVersion === pkgVersion ? rootVersion : `${rootVersion}/${pkgVersion}`
+ },
+ write: (root, version) => {
+ const j = readJson(root, 'desktop-app/package-lock.json')
+ j.version = version
+ if (j.packages?.['']) j.packages[''].version = version
+ writeJson(root, 'desktop-app/package-lock.json', j)
+ },
+ },
+ {
+ name: 'releaseManifest.desktopVersion',
+ assert: 'equals',
+ read: root => manifestField(root, 'desktopVersion'),
+ writtenBy: 'update-desktop-release-manifest.mjs',
+ },
+ {
+ name: 'releaseManifest.minimumDesktopVersion',
+ assert: 'floor',
+ read: root => manifestField(root, 'minimumDesktopVersion'),
+ writtenBy: 'update-desktop-release-manifest.mjs --minimum-desktop-version',
+ },
+ {
+ name: 'releaseManifest.releaseId',
+ assert: 'explicit',
+ read: root => manifestField(root, 'releaseId'),
+ writtenBy: 'update-desktop-release-manifest.mjs --release-id',
+ },
+ {
+ name: 'releaseManifest.externalRestApiVersion',
+ assert: 'counter',
+ counterPackage: 'external-rest-api/package.json',
+ read: root => manifestField(root, 'externalRestApiVersion'),
+ writtenBy: 'update-desktop-release-manifest.mjs',
+ },
+ {
+ name: 'releaseManifest.rpcProxyVersion',
+ assert: 'counter',
+ counterPackage: 'rpc-proxy/package.json',
+ read: root => manifestField(root, 'rpcProxyVersion'),
+ writtenBy: 'update-desktop-release-manifest.mjs',
+ },
+]
+
+export function readCounterPackage(root, rel) {
+ return readJson(root, rel).version
+}
diff --git a/scripts/release/update-desktop-release-manifest.mjs b/scripts/release/update-desktop-release-manifest.mjs
index bf1d3148e..e3c1a1b2b 100644
--- a/scripts/release/update-desktop-release-manifest.mjs
+++ b/scripts/release/update-desktop-release-manifest.mjs
@@ -2,6 +2,7 @@
import { execFileSync } from 'node:child_process'
import fs from 'node:fs'
import path from 'node:path'
+import { SEMVER_RE, compareVersions, parseManifest } from './release-coordinates.mjs'
const ROOT = process.cwd()
const MANIFEST_PATH = 'external-rest-api/src/releaseManifest.ts'
@@ -32,16 +33,6 @@ function gitShow(ref, filePath) {
}
}
-function parseManifest(raw) {
- const match = raw.match(/export const releaseManifest: ReleaseManifest = (\{[\s\S]*?\n\})/)
- if (!match) return null
- const normalized = match[1]
- .replace(/([{,]\s*)([a-zA-Z][a-zA-Z0-9]*):/g, '$1"$2":')
- .replace(/'/g, '"')
- .replace(/,\s*}/g, '}')
- return JSON.parse(normalized)
-}
-
function currentManifest() {
return parseManifest(fs.readFileSync(path.join(ROOT, MANIFEST_PATH), 'utf8'))
}
@@ -87,25 +78,6 @@ export const releaseManifest: ReleaseManifest = ${JSON.stringify(manifest, null,
`
}
-const SEMVER_RE = /^\d+\.\d+\.\d+$/
-
-// Numeric MAJOR.MINOR.PATCH comparison. Deliberately matches the semantics of
-// compareSemverLike in desktop-app/src/appService.ts:177, which is what the
-// update gate at :840 evaluates at runtime. No prerelease handling on either
-// side, so the two cannot disagree.
-//
-// TEMPORARY: Task 5 creates scripts/release/release-coordinates.mjs and
-// replaces this local definition with an import from it. It lives here now
-// only because that module does not exist yet.
-function compareVersions(a, b) {
- const pa = a.split('.').map(Number)
- const pb = b.split('.').map(Number)
- for (let i = 0; i < 3; i += 1) {
- if (pa[i] !== pb[i]) return pa[i] < pb[i] ? -1 : 1
- }
- return 0
-}
-
function validate(manifest, versions, options = {}) {
const fields = options.deferDesktopRelease
? ['externalRestApiVersion', 'rpcProxyVersion']
diff --git a/scripts/release/validate-release-tag.mjs b/scripts/release/validate-release-tag.mjs
new file mode 100755
index 000000000..f376e902d
--- /dev/null
+++ b/scripts/release/validate-release-tag.mjs
@@ -0,0 +1,70 @@
+#!/usr/bin/env node
+// The declared-agreement half of the release checker. Pure tree reads, so it
+// 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 are created by release-images.yml on the tag, so they cannot
+// pre-exist here. Existence is that workflow's job.
+//
+// node scripts/release/validate-release-tag.mjs --version 0.6.0
+import process from 'node:process'
+import {
+ COORDINATES,
+ SEMVER_RE,
+ compareVersions,
+ readCounterPackage,
+} from './release-coordinates.mjs'
+
+const ROOT = process.cwd()
+
+function argValue(name) {
+ const i = process.argv.indexOf(name)
+ return i >= 0 ? process.argv[i + 1] : ''
+}
+
+const version = (argValue('--version') || '').replace(/^v/, '')
+if (!SEMVER_RE.test(version)) {
+ console.error(
+ `--version must be MAJOR.MINOR.PATCH (a leading v is stripped), got: ${version || '(missing)'}`
+ )
+ process.exit(1)
+}
+
+const failures = []
+
+for (const coordinate of COORDINATES) {
+ const actual = coordinate.read(ROOT)
+
+ if (coordinate.assert === 'equals' && actual !== version) {
+ failures.push(`${coordinate.name}=${actual}, expected ${version}`)
+ }
+
+ if (coordinate.assert === 'floor') {
+ if (!SEMVER_RE.test(actual)) {
+ failures.push(`${coordinate.name}=${actual} is not MAJOR.MINOR.PATCH`)
+ } else if (compareVersions(actual, version) > 0) {
+ failures.push(`${coordinate.name}=${actual} is greater than the release version ${version}`)
+ }
+ }
+
+ if (coordinate.assert === 'explicit' && (!actual || actual === 'local')) {
+ failures.push(`${coordinate.name}=${actual || '(empty)'} was never set explicitly`)
+ }
+
+ if (coordinate.assert === 'counter') {
+ const expected = readCounterPackage(ROOT, coordinate.counterPackage)
+ if (actual !== expected) {
+ failures.push(
+ `${coordinate.name}=${actual}, expected ${expected} from ${coordinate.counterPackage}`
+ )
+ }
+ }
+}
+
+if (failures.length > 0) {
+ console.error(`release ${version} has ${failures.length} disagreeing coordinate(s):`)
+ for (const f of failures) console.error(` ${f}`)
+ process.exit(1)
+}
+
+console.log(`release ${version}: all ${COORDINATES.length} coordinates agree`)
diff --git a/scripts/tests/test-precommit-release-manifest-ignore.sh b/scripts/tests/test-precommit-release-manifest-ignore.sh
index 604b19bb2..aa335ca6e 100755
--- a/scripts/tests/test-precommit-release-manifest-ignore.sh
+++ b/scripts/tests/test-precommit-release-manifest-ignore.sh
@@ -31,6 +31,7 @@ make_repo() {
cp "$REPO_ROOT/scripts/precommit/bump-staged-package-versions.mjs" "$d/scripts/precommit/"
cp "$REPO_ROOT/scripts/prettier/paths.mjs" "$d/scripts/prettier/"
cp "$REPO_ROOT/scripts/release/update-desktop-release-manifest.mjs" "$d/scripts/release/"
+ cp "$REPO_ROOT/scripts/release/release-coordinates.mjs" "$d/scripts/release/"
printf '{\n "name": "external-rest-api",\n "version": "0.1.60"\n}\n' \
> "$d/external-rest-api/package.json"
printf '{\n "name": "rpc-proxy",\n "version": "0.1.51"\n}\n' \
diff --git a/scripts/tests/test-release-coordinates.sh b/scripts/tests/test-release-coordinates.sh
index d1d4ed10d..c5ea905b7 100755
--- a/scripts/tests/test-release-coordinates.sh
+++ b/scripts/tests/test-release-coordinates.sh
@@ -240,11 +240,339 @@ assert_ordering_check_fails_against_unpatched_script() {
rm -rf "$d"
}
+assert_prepare_release_writes_every_coordinate() {
+ 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
+ cp -R "$REPO_ROOT/scripts" "$d/scripts"
+
+ if ( cd "$d" && node scripts/release/prepare-release.mjs \
+ --version 0.6.0 --release-id test-1111111 >/dev/null 2>&1 ); then
+ local pv lv dv min
+ pv="$(grep '"version"' "$d/desktop-app/package.json" | sed 's/.*: "\(.*\)".*/\1/')"
+ lv="$(node -e 'const j=require(process.argv[1]);console.log(j.version,j.packages[""].version)' "$d/desktop-app/package-lock.json")"
+ dv="$(manifest_field "$d" desktopVersion)"
+ min="$(manifest_field "$d" minimumDesktopVersion)"
+ if [ "$pv" = "0.6.0" ] && [ "$lv" = "0.6.0 0.6.0" ] && [ "$dv" = "0.6.0" ] && [ "$min" = "0.1.252" ]; then
+ pass "prepare-release writes package.json, both lockfile sites, and the manifest"
+ else
+ fail "coordinates after prepare-release: pkg=$pv lock='$lv' manifest=$dv floor=$min"
+ fi
+ else
+ fail "prepare-release.mjs exited non-zero"
+ fi
+ rm -rf "$d"
+}
+
+assert_prepare_release_leaves_a_same_string_dependency_alone() {
+ 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
+ cp -R "$REPO_ROOT/scripts" "$d/scripts"
+ node -e '
+ const fs = require("fs"), p = process.argv[1]
+ const j = JSON.parse(fs.readFileSync(p, "utf8"))
+ j.dependencies = { "some-dep": "0.5.0" }
+ fs.writeFileSync(p, JSON.stringify(j, null, 2) + "\n")
+ ' "$d/desktop-app/package.json"
+
+ ( cd "$d" && node scripts/release/prepare-release.mjs --version 0.6.0 --release-id t >/dev/null 2>&1 )
+ local dep; dep="$(node -e 'console.log(require(process.argv[1]).dependencies["some-dep"])' "$d/desktop-app/package.json")"
+ if [ "$dep" = "0.5.0" ]; then
+ pass "a dependency pinned to the old version string is untouched"
+ else
+ fail "dependency pin was rewritten to $dep"
+ fi
+ rm -rf "$d"
+}
+
+assert_prepare_release_rejects_a_non_greater_version() {
+ 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
+ cp -R "$REPO_ROOT/scripts" "$d/scripts"
+ if ( cd "$d" && node scripts/release/prepare-release.mjs --version 0.5.0 --release-id t >/dev/null 2>&1 ); then
+ fail "prepare-release accepted a version not greater than current"
+ else
+ pass "prepare-release rejects a version not greater than current"
+ fi
+ rm -rf "$d"
+}
+
+assert_prepare_release_rejects_a_bad_version_shape() {
+ 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
+ cp -R "$REPO_ROOT/scripts" "$d/scripts"
+ if ( cd "$d" && node scripts/release/prepare-release.mjs --version 0.6 --release-id t >/dev/null 2>&1 ); then
+ fail "prepare-release accepted a non MAJOR.MINOR.PATCH version"
+ else
+ pass "prepare-release rejects a non MAJOR.MINOR.PATCH version"
+ fi
+ rm -rf "$d"
+}
+
+assert_release_id_is_never_local() {
+ 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
+ cp -R "$REPO_ROOT/scripts" "$d/scripts"
+ if ( cd "$d" && node scripts/release/prepare-release.mjs --version 0.6.0 >/dev/null 2>&1 ); then
+ fail "prepare-release ran without --release-id"
+ else
+ pass "prepare-release requires an explicit --release-id"
+ fi
+ rm -rf "$d"
+}
+
+assert_validate_release_tag_catches_each_coordinate() {
+ local d; 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
+ 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
+ fail "validate-release-tag rejected a coherent tree"
+ rm -rf "$d"; return
+ fi
+
+ # This breaks a single `equals` coordinate (desktop-app/package.json) and
+ # confirms the checker catches it. The other assertion kinds -- floor,
+ # explicit, counter -- get their own dedicated negative cases below
+ # (assert_floor_above_release_version_is_rejected_by_the_checker,
+ # assert_floor_non_semver_is_rejected_by_the_checker,
+ # assert_explicit_release_id_is_rejected_when_local_or_empty,
+ # assert_counter_mismatch_is_rejected_by_the_checker), not by looping here.
+ local broke_all=1
+ node -e '
+ const fs=require("fs"),p=process.argv[1]
+ const j=JSON.parse(fs.readFileSync(p,"utf8")); j.version="0.6.1"
+ fs.writeFileSync(p,JSON.stringify(j,null,2)+"\n")
+ ' "$d/desktop-app/package.json"
+ ( cd "$d" && node scripts/release/validate-release-tag.mjs --version 0.6.0 >/dev/null 2>&1 ) && broke_all=0
+
+ if [ "$broke_all" = "1" ]; then
+ pass "validate-release-tag catches a disagreeing coordinate"
+ else
+ fail "validate-release-tag passed with desktop-app/package.json at 0.6.1"
+ fi
+ rm -rf "$d"
+}
+
+assert_validate_release_tag_rejects_a_renamed_manifest_export() {
+ local d; d="$(mktemp -d)"
+ mkdir -p "$d/desktop-app" "$d/external-rest-api/src" "$d/rpc-proxy"
+ printf '{\n "name": "desktop-app",\n "version": "0.6.0"\n}\n' > "$d/desktop-app/package.json"
+ printf '{\n "name": "desktop-app",\n "version": "0.6.0",\n "packages": {\n "": {\n "version": "0.6.0"\n }\n }\n}\n' > "$d/desktop-app/package-lock.json"
+ printf '{\n "name": "external-rest-api",\n "version": "0.1.60"\n}\n' > "$d/external-rest-api/package.json"
+ printf '{\n "name": "rpc-proxy",\n "version": "0.1.51"\n}\n' > "$d/rpc-proxy/package.json"
+ # The export is renamed but the field values are otherwise coherent with
+ # the release. A field-by-field regex over the whole file would still find
+ # these lines and pass; manifestField must instead fail to find the
+ # `releaseManifest` export at all, so every manifest coordinate reads as
+ # empty and the checker rejects the tree.
+ cat > "$d/external-rest-api/src/releaseManifest.ts" <<'EOF'
+export type ReleaseManifest = {
+ releaseId: string
+ externalRestApiVersion: string
+ rpcProxyVersion: string
+ desktopVersion: string
+ minimumDesktopVersion: string
+}
+
+export const releaseManifestRENAMED: ReleaseManifest = {
+ releaseId: 'fixture-0000000',
+ externalRestApiVersion: '0.1.60',
+ rpcProxyVersion: '0.1.51',
+ desktopVersion: '0.6.0',
+ minimumDesktopVersion: '0.1.252',
+}
+EOF
+ 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
+ fail "validate-release-tag passed against a renamed releaseManifest export"
+ else
+ pass "validate-release-tag rejects a manifest whose export is renamed"
+ fi
+ rm -rf "$d"
+}
+
+assert_validate_release_tag_ignores_a_decoy_object() {
+ local d; d="$(mktemp -d)"
+ mkdir -p "$d/desktop-app" "$d/external-rest-api/src" "$d/rpc-proxy"
+ printf '{\n "name": "desktop-app",\n "version": "0.6.0"\n}\n' > "$d/desktop-app/package.json"
+ printf '{\n "name": "desktop-app",\n "version": "0.6.0",\n "packages": {\n "": {\n "version": "0.6.0"\n }\n }\n}\n' > "$d/desktop-app/package-lock.json"
+ printf '{\n "name": "external-rest-api",\n "version": "0.1.60"\n}\n' > "$d/external-rest-api/package.json"
+ printf '{\n "name": "rpc-proxy",\n "version": "0.1.51"\n}\n' > "$d/rpc-proxy/package.json"
+ # A decoy object with the SAME field names sits above the real export and
+ # carries values that would pass. The real `releaseManifest` export below
+ # it carries values that must fail. A field-by-field regex over the whole
+ # file matches the decoy's lines first (they appear first) and passes; the
+ # checker must read the actual `releaseManifest` export instead.
+ cat > "$d/external-rest-api/src/releaseManifest.ts" <<'EOF'
+export type ReleaseManifest = {
+ releaseId: string
+ externalRestApiVersion: string
+ rpcProxyVersion: string
+ desktopVersion: string
+ minimumDesktopVersion: string
+}
+
+const decoy = {
+ releaseId: 'decoy-0000000',
+ externalRestApiVersion: '0.1.60',
+ rpcProxyVersion: '0.1.51',
+ desktopVersion: '0.6.0',
+ minimumDesktopVersion: '0.1.252',
+}
+
+export const releaseManifest: ReleaseManifest = {
+ releaseId: 'wrong-0000000',
+ externalRestApiVersion: '9.9.9',
+ rpcProxyVersion: '9.9.9',
+ desktopVersion: '9.9.9',
+ minimumDesktopVersion: '9.9.9',
+}
+EOF
+ 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
+ fail "validate-release-tag passed by reading a decoy object instead of the real export"
+ else
+ pass "validate-release-tag reads the real releaseManifest export, not a decoy placed above it"
+ fi
+ rm -rf "$d"
+}
+
+assert_floor_is_checked_as_a_ceiling_not_an_equality() {
+ local d; 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
+ 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
+ pass "a floor below the release version is accepted, not required to equal it"
+ else
+ fail "validate-release-tag required minimumDesktopVersion to equal the version"
+ fi
+ rm -rf "$d"
+}
+
+assert_floor_above_release_version_is_rejected_by_the_checker() {
+ local d; d="$(mktemp -d)"
+ # Floor 0.9.9 is ABOVE the release version 0.6.0 -- the dangerous
+ # direction. This whole workstream exists because a wrong floor
+ # force-updates every existing desktop install; the checker must catch
+ # this before the tag, not just accept a floor that happens to be low.
+ make_fixture "$d" 0.6.0 0.1.60 0.1.51 0.6.0 0.9.9 0.1.60 0.1.51
+ 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
+ fail "validate-release-tag accepted a floor (0.9.9) above the release version (0.6.0)"
+ else
+ pass "validate-release-tag rejects a floor above the release version"
+ fi
+ rm -rf "$d"
+}
+
+assert_floor_non_semver_is_rejected_by_the_checker() {
+ local d; d="$(mktemp -d)"
+ make_fixture "$d" 0.6.0 0.1.60 0.1.51 0.6.0 0.1 0.1.60 0.1.51
+ 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
+ fail "validate-release-tag accepted a non MAJOR.MINOR.PATCH floor (0.1)"
+ else
+ pass "validate-release-tag rejects a non MAJOR.MINOR.PATCH floor"
+ fi
+ rm -rf "$d"
+}
+
+assert_explicit_release_id_is_rejected_when_local_or_empty() {
+ local d; 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
+ cp -R "$REPO_ROOT/scripts" "$d/scripts"
+ local manifest="$d/external-rest-api/src/releaseManifest.ts"
+
+ sed -i.bak "s/releaseId: 'fixture-0000000'/releaseId: 'local'/" "$manifest"
+ local local_rejected=0
+ ( cd "$d" && node scripts/release/validate-release-tag.mjs --version 0.6.0 >/dev/null 2>&1 ) || local_rejected=1
+
+ sed -i.bak "s/releaseId: 'local'/releaseId: ''/" "$manifest"
+ local empty_rejected=0
+ ( cd "$d" && node scripts/release/validate-release-tag.mjs --version 0.6.0 >/dev/null 2>&1 ) || empty_rejected=1
+
+ if [ "$local_rejected" = "1" ] && [ "$empty_rejected" = "1" ]; then
+ pass "validate-release-tag rejects releaseId of 'local' and of an empty string"
+ else
+ fail "expected both 'local' and empty releaseId rejected (local_rejected=$local_rejected empty_rejected=$empty_rejected)"
+ fi
+ rm -rf "$d"
+}
+
+assert_counter_mismatch_is_rejected_by_the_checker() {
+ local d; d="$(mktemp -d)"
+ # manifest externalRestApiVersion (0.1.61) disagrees with
+ # external-rest-api/package.json (0.1.60) -- checked against the counter's
+ # OWN package, not the release version.
+ make_fixture "$d" 0.6.0 0.1.60 0.1.51 0.6.0 0.1.252 0.1.61 0.1.51
+ 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
+ fail "validate-release-tag accepted externalRestApiVersion disagreeing with external-rest-api/package.json"
+ else
+ pass "validate-release-tag rejects a counter that disagrees with its own package.json"
+ fi
+ rm -rf "$d"
+}
+
+assert_every_coordinate_has_a_case() {
+ local declared cases
+ declared="$(node -e '
+ import("'"$REPO_ROOT"'/scripts/release/release-coordinates.mjs")
+ .then(m => console.log(m.COORDINATES.length))
+ ')"
+ # Count DEFINITIONS only. A bare "^assert_" also counts every invocation in
+ # the call block at the bottom, which roughly doubles the number and makes
+ # this check pass no matter what.
+ cases="$(grep -cE '^assert_[a-z_]+\(\) \{' "$REPO_ROOT/scripts/tests/test-release-coordinates.sh")"
+ if [ "$cases" -ge "$declared" ]; then
+ pass "each declared coordinate has at least one case ($declared coordinates, $cases assertions)"
+ else
+ fail "$declared coordinates declared but only $cases assertions"
+ fi
+}
+
+# Guards against the opposite failure mode from assert_every_coordinate_has_a_case:
+# a case can be DEFINED (so it counts toward that check) and still never be
+# CALLED from the block below, which makes it permanently dead -- the suite
+# prints all-PASS while the dead case never runs. A stated PASS-count in a
+# plan document is a description, not a source of truth; this check compares
+# against what the file itself defines and calls, so it can't go stale that
+# way.
+assert_every_defined_case_is_invoked() {
+ local defined invoked missing
+ defined="$(grep -oE '^assert_[a-z_]+\(\) \{' "$REPO_ROOT/scripts/tests/test-release-coordinates.sh" \
+ | sed -E 's/\(\) \{$//' | sort -u)"
+ invoked="$(grep -oE '^assert_[a-z_]+$' "$REPO_ROOT/scripts/tests/test-release-coordinates.sh" | sort -u)"
+ missing="$(comm -23 <(printf '%s\n' "$defined") <(printf '%s\n' "$invoked"))"
+ if [ -z "$missing" ]; then
+ pass "every defined assert_ case is invoked in the call block"
+ else
+ fail "defined but never invoked: $(printf '%s ' $missing)"
+ fi
+}
+
assert_floor_is_not_dragged_by_a_desktop_bump
assert_floor_above_desktop_is_rejected
assert_explicit_minimum_flag_is_honoured
assert_unreadable_manifest_does_not_synthesize_a_floor
assert_previous_ref_does_not_revert_a_raised_floor
assert_ordering_check_fails_against_unpatched_script
+assert_prepare_release_writes_every_coordinate
+assert_prepare_release_leaves_a_same_string_dependency_alone
+assert_prepare_release_rejects_a_non_greater_version
+assert_prepare_release_rejects_a_bad_version_shape
+assert_release_id_is_never_local
+assert_validate_release_tag_catches_each_coordinate
+assert_validate_release_tag_rejects_a_renamed_manifest_export
+assert_validate_release_tag_ignores_a_decoy_object
+assert_floor_is_checked_as_a_ceiling_not_an_equality
+assert_floor_above_release_version_is_rejected_by_the_checker
+assert_floor_non_semver_is_rejected_by_the_checker
+assert_explicit_release_id_is_rejected_when_local_or_empty
+assert_counter_mismatch_is_rejected_by_the_checker
+assert_every_coordinate_has_a_case
+assert_every_defined_case_is_invoked
exit $FAIL