Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
fix(release): accept any tag on HEAD; say a Homebrew upgrade left the CLI alone
KageBinary5ddca258f0cf
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 3e89e767..f487f2bf 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -187,10 +187,15 @@ jobs:elseTAG="${INPUT_TAG:-$REF_NAME}"echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"- # What is built must be exactly the tag that names it.- AT=$(git describe --exact-match --tags HEAD 2>/dev/null || true)- if [ "$AT" != "$TAG" ]; then- echo "::error::HEAD is ${AT:-not at a tag}, not $TAG. Refusing to build $TAG from another commit."+ # What is built must be exactly the tag that names it. Any of the+ # tags on HEAD, not `git describe --exact-match`: describe names one+ # tag per commit, so a commit carrying several (v0.10.0-rc.1 to+ # rc.4 share one) would refuse every tag on it but that one.+ # Captured first, not piped into `grep -q`: under pipefail an early+ # grep exit can fail the pipeline on git's SIGPIPE.+ AT=$(git tag --points-at HEAD)+ if ! grep -Fxq -- "$TAG" <<<"$AT"; then+ echo "::error::HEAD $(git rev-parse --short HEAD) is not tagged $TAG (its tags: ${AT:-none}). Refusing to build $TAG from another commit."exit 1fifidiff --git a/ix-cli/src/cli/__tests__/upgrade-homebrew.test.ts b/ix-cli/src/cli/__tests__/upgrade-homebrew.test.tsindex 151751e0..410d92af 100644--- a/ix-cli/src/cli/__tests__/upgrade-homebrew.test.ts+++ b/ix-cli/src/cli/__tests__/upgrade-homebrew.test.ts@@ -1,9 +1,21 @@// Copyright 2026 Ix Infrastructure Inc.-import { describe, expect, it } from "vitest";+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { dirname, join } from "node:path";+import { fileURLToPath } from "node:url";+import { Command } from "commander";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { homebrewInstall } from "../commands/upgrade.js";+const mocks = vi.hoisted(() => ({+ execFileSync: vi.fn((..._args: unknown[]) => ""),+}));++vi.mock("child_process", () => ({ execFileSync: mocks.execFileSync }));+vi.mock("node:child_process", () => ({ execFileSync: mocks.execFileSync }));+describe("homebrewInstall", () => {it("recognises an entry point inside a Homebrew Cellar", () => {expect(homebrewInstall("/opt/homebrew/Cellar/ix/0.12.0/libexec/dist/cli/main.js")).toBe(true);@@ -17,3 +29,73 @@ describe("homebrewInstall", () => {expect(homebrewInstall("/opt/homebrew/Cellar/other/1.0/bin/main.js")).toBe(false);});});++describe("ix upgrade on a Homebrew install with a newer CLI released", () => {+ const TEST_DIR = dirname(fileURLToPath(import.meta.url));+ const CURRENT = JSON.parse(readFileSync(join(TEST_DIR, "..", "..", "..", "package.json"), "utf-8"))+ .version as string;+ let home: string;+ let originalIxHome: string | undefined;+ let originalArgv1: string | undefined;++ beforeEach(() => {+ vi.resetModules();+ vi.clearAllMocks();+ originalIxHome = process.env.IX_HOME;+ originalArgv1 = process.argv[1];+ home = mkdtempSync(join(tmpdir(), "ix-upgrade-homebrew-"));+ process.env.IX_HOME = home;+ mkdirSync(join(home, "backend"), { recursive: true });+ writeFileSync(join(home, ".backend-version"), "1.0.17");+ writeFileSync(+ join(home, "backend", "docker-compose.yml"),+ "services:\n memory-layer:\n image: ghcr.io/ix-infrastructure/ix-memory-layer:latest\n",+ );+ process.argv[1] = "/opt/homebrew/Cellar/ix/0.0.1/libexec/dist/cli/main.js";+ vi.stubGlobal(+ "fetch",+ vi.fn(async (input: string | URL | Request) => {+ const url = String(input);+ if (url.includes("/ix-memory-layer-dist/")) {+ return new Response(JSON.stringify({ tag_name: "v1.0.17" }), { status: 200 });+ }+ if (url.includes("/ix-compass-dist/")) return new Response("", { status: 404 });+ return new Response(JSON.stringify({ tag_name: "v99.0.0" }), { status: 200 });+ }),+ );+ });++ afterEach(() => {+ vi.restoreAllMocks();+ vi.unstubAllGlobals();+ rmSync(home, { recursive: true, force: true });+ if (originalIxHome === undefined) delete process.env.IX_HOME;+ else process.env.IX_HOME = originalIxHome;+ if (originalArgv1 !== undefined) process.argv[1] = originalArgv1;+ });++ it("points at brew, downloads nothing, and does not close with [ok] up to date", async () => {+ expect(CURRENT).not.toBe("99.0.0");+ const { registerUpgradeCommand } = await import("../commands/upgrade.js");+ const program = new Command();+ program.name("ix").exitOverride();+ registerUpgradeCommand(program);++ const output: string[] = [];+ const capture = (...values: unknown[]) => void output.push(values.join(" "));+ const log = vi.spyOn(console, "log").mockImplementation(capture);+ const error = vi.spyOn(console, "error").mockImplementation(capture);+ try {+ await program.parseAsync(["upgrade"], { from: "user" });+ } finally {+ log.mockRestore();+ error.mockRestore();+ }+ const text = output.join("\n");++ expect(text).toContain("brew upgrade ix");+ expect(mocks.execFileSync.mock.calls.some(([command]) => command === "curl")).toBe(false);+ expect(text).not.toContain("[ok] ix is up to date");+ expect(text).toContain("ix upgrade finished with the CLI unchanged");+ });+});diff --git a/ix-cli/src/cli/commands/upgrade.ts b/ix-cli/src/cli/commands/upgrade.tsindex ab8dfbfd..33e13e4d 100644--- a/ix-cli/src/cli/commands/upgrade.ts+++ b/ix-cli/src/cli/commands/upgrade.ts@@ -169,6 +169,17 @@ function splitVersion(v: string): [number[], string[]] {return [nums, pre ? pre.split(".") : []];}+/** Is the running CLI's entry point inside a Homebrew Cellar? */+export function homebrewInstall(entryPoint: string): boolean {+ let real = entryPoint;+ try {+ real = realpathSync(entryPoint);+ } catch {+ // keep the path as given+ }+ return /[\\/]Cellar[\\/]ix[\\/]/.test(real);+}+/*** Is `latest` a higher version than `current`?*@@ -184,17 +195,6 @@ function splitVersion(v: string): [number[], string[]] {* identifiers left to right, numeric ones numerically and below alphanumeric* ones, and a longer identifier list wins when all preceding fields are equal.*/-/** Is the running CLI's entry point inside a Homebrew Cellar? */-export function homebrewInstall(entryPoint: string): boolean {- let real = entryPoint;- try {- real = realpathSync(entryPoint);- } catch {- // keep the path as given- }- return /[\\/]Cellar[\\/]ix[\\/]/.test(real);-}-export function isNewer(latest: string, current: string): boolean {const [lNums, lPre] = splitVersion(latest);const [cNums, cPre] = splitVersion(current);@@ -1454,6 +1454,9 @@ export function registerUpgradeCommand(program: Command): void {// is up to date` and exit 0, which is what a script or a user skimming// the last line believed.const failures: string[] = [];+ // A Homebrew install whose CLI this run declined to touch. The closing+ // line must not then say "[ok] ix is up to date" under the brew hint.+ let cliLeftToBrew = false;const cliUpToDate = !isNewer(latest, current);if (cliUpToDate) {@@ -1465,6 +1468,7 @@ export function registerUpgradeCommand(program: Command): void {if (!opts.check && homebrewInstall(process.argv[1] ?? "")) {// Unpacking a release over a Homebrew keg would replace files brew// owns, and the next `brew upgrade` would undo it. Brew updates it.+ cliLeftToBrew = true;console.log(` This ix was installed with Homebrew. Update it with: ${chalk.cyan("brew upgrade ix")}`);} else if (!opts.check) {const platform = detectPlatform();@@ -1882,16 +1886,17 @@ export function registerUpgradeCommand(program: Command): void {console.log("");// Two independent reasons the run may not end clean, and they cannot- // both apply: `backendUpgradeSkipped` requires an install run, while- // `closingStatus` only reports outstanding work under `--check`. The- // skipped-backend case is checked first because it describes work this- // run declined to do, which outranks work it merely found.+ // both apply: `backendUpgradeSkipped` and `cliLeftToBrew` require an+ // install run, while `closingStatus` only reports outstanding work under+ // `--check`. The declined steps are checked first because they describe+ // work this run declined to do, which outranks work it merely found.const closing = closingStatus(opts.check, outstanding, failures);if (closing.failed) {console.log(`[!!] ix upgrade did not complete: ${closing.summary} failed (see above)`);process.exitCode = 1;- } else if (backendUpgradeSkipped) {- console.log("[!!] ix upgrade finished with the backend unchanged");+ } else if (cliLeftToBrew || backendUpgradeSkipped) {+ if (cliLeftToBrew) console.log("[!!] ix upgrade finished with the CLI unchanged: run brew upgrade ix");+ if (backendUpgradeSkipped) console.log("[!!] ix upgrade finished with the backend unchanged");} else if (closing.upToDate) {console.log("[ok] ix is up to date");} else {