Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

ci(release): order the pinned compare base by real semver; fixture-test it

xerj-org7e8b24a7af08
diff --git a/.github/scripts/prev_tag.sh b/.github/scripts/prev_tag.sh
new file mode 100755
index 000000000..8d0206270
--- /dev/null
+++ b/.github/scripts/prev_tag.sh
@@ -0,0 +1,127 @@
+#!/bin/sh
+# prev_tag.sh - the release-notes compare base (previous_tag_name) for a cut.
+#
+# WHY THIS EXISTS
+# GitHub anchors auto-generated release notes ("Full Changelog") on the most
+# recently PUBLISHED release. Since the daily pack-rust-vulns-* corpus-pack
+# releases started, that anchor is usually a corpus pack, not the previous
+# engine release: v1.0.0-rc.78 shipped comparing
+# pack-rust-vulns-2026-09-29...v1.0.0-rc.78 and had to be hand-patched via
+# REST. PR #1069 stopped trusting that auto-detection and pinned the base
+# with `git tag --sort=-v:refname`, but plain version sort orders a final
+# BELOW its own pre-releases (v1.0.0-rc.79 > v1.0.0), so the first v1.0.1
+# cut would have compared against v1.0.0-rc.79 rather than v1.0.0 — the
+# opposite of what #1069's message claims. `-c versionsort.suffix=-rc`
+# orders a prerelease below its final (git >= 2.36; GitHub runners ship
+# newer, and the fixture below fails loudly on a git that does not honor
+# it). This script is the single derivation, checked in with its own
+# fixture test so the ordering is provable without cutting a release.
+#
+# RULES
+# - Candidates match ^v[0-9]+\.[0-9]+\.[0-9]+ — an rc suffix counts, an rc
+# IS a real xerj release. pack-*, backup/* and rb* tags never match.
+# - The answer is the version-successor of the tag being cut: the next
+# entry below it in descending version order. A fresh cut therefore gets
+# the previous release, and re-dispatching an OLD tag rebuilds notes
+# against that release's own predecessor instead of today's newest tag.
+# A current tag not in the list yet (a hypothetical) takes the highest
+# entry.
+# - Nothing below it (first-ever tag): empty output, exit 0 — the workflow
+# falls back to GitHub's auto-generated notes.
+#
+# USAGE
+# bash .github/scripts/prev_tag.sh <tag-being-cut> # prints the base, or nothing
+# bash .github/scripts/prev_tag.sh --self-test # fixture assertions
+#
+# Requires: git >= 2.36 (versionsort.suffix), run in a checkout that has the
+# tags (the release job checks out with fetch-depth: 0).
+
+set -eu
+
+# All release tags, highest version first.
+vtags() {
+ git -c versionsort.suffix=-rc tag -l 'v[0-9]*' --sort=-v:refname \
+ | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+'
+}
+
+# $1 = the tag being cut. Version-successor semantics, see header. awk
+# detail: `exit` still runs END, so END must re-check `have` before
+# applying the not-in-list fallback.
+prev_tag() {
+ vtags | awk -v cur="$1" '
+ NR == 1 { head = $0 }
+ $0 == cur { have = 1; next }
+ have { print; exit }
+ END { if (!have && head != "") print head }
+ '
+}
+
+case "${1:-}" in
+ --self-test) ;;
+ '')
+ printf 'usage: prev_tag.sh <tag-being-cut> | --self-test\n' >&2
+ exit 2 ;;
+ *)
+ prev_tag "$1"
+ exit 0 ;;
+esac
+
+# ── self-test: fixture repos whose tag CREATION order is not their version
+# order, so the assertions below fail for a creatordate sort (the pack
+# poison) and for plain --sort=-v:refname (final below its rcs). ─────────
+fails=0
+note() { printf ' %s\n' "$1"; }
+fail() { printf 'FAIL %s\n' "$1"; fails=$((fails + 1)); }
+pass() { printf 'ok %s\n' "$1"; }
+
+# fixture <tag>... — fresh repo, one empty commit, tags created in the order
+# given (identity is inline: a runner's global git identity does not apply to
+# a repo that actions/checkout did not create).
+fixture() {
+ fx="$(mktemp -d)"
+ git -C "$fx" init -q 2>/dev/null
+ git -C "$fx" -c [email protected] -c user.name=selftest \
+ commit -q --allow-empty -m fixture
+ for t in "$@"; do git -C "$fx" tag "$t"; done
+ printf '%s' "$fx"
+}
+
+# check <repo> <current-tag> <expected|-> <description>
+check() {
+ got="$(cd "$1" && prev_tag "$2")"
+ if [ "${got:--}" = "${3:--}" ]; then
+ pass "$4"
+ else
+ fail "$4: expected '${3:-<empty>}', got '${got:-<empty>}'"
+ fi
+}
+
+echo '== fixture 1: rc chain with newer-created pack/rc.9 noise (todays shape) =='
+f1="$(fixture v0.9.0 v1.0.0-rc.8 v1.0.0-rc.78 v1.0.0-rc.77 v1.0.0-rc.9 \
+ pack-rust-vulns-2026-09-30 backup/old rb12)"
+check "$f1" v1.0.0-rc.79 v1.0.0-rc.78 \
+ 'hypothetical cut today: previous v-tag, not pack-rust-vulns-2026-09-30 (created later) nor v1.0.0-rc.9'
+check "$f1" v1.0.0-rc.78 v1.0.0-rc.77 \
+ 're-dispatch of the newest tag: its own predecessor'
+rm -rf "$f1"
+
+echo '== fixture 2: final among its rcs (the PR #1069 latent ordering bug) =='
+f2="$(fixture v1.0.0-rc.8 v1.0.0-rc.79 v1.0.0 v1.0.1)"
+check "$f2" v1.0.1 v1.0.0 \
+ 'v1.0.1 cut compares against v1.0.0, not v1.0.0-rc.79 (plain --sort=-v:refname picks the rc)'
+check "$f2" v1.0.0 v1.0.0-rc.79 \
+ 'rebuilding the v1.0.0 release compares against v1.0.0-rc.79, not the newer v1.0.1'
+rm -rf "$f2"
+
+echo '== fixture 3: first-ever tag =='
+f3="$(fixture v0.1.0)"
+check "$f3" v0.1.0 - \
+ 'no predecessor: empty output, workflow falls back to auto-generated notes'
+rm -rf "$f3"
+
+if [ "$fails" -eq 0 ]; then
+ printf 'PASS prev_tag.sh: 5/5 fixture assertions\n'
+else
+ printf 'FAIL prev_tag.sh: %d fixture assertion(s)\n' "$fails"
+ exit 1
+fi
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 8b1a8267c..cab9281e0 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -307,11 +307,17 @@ jobs:
run: |
set -euo pipefail
CURRENT="${GITHUB_REF_NAME}"
- # Highest version tag that is not the one being cut: --sort=-v:refname
- # orders v1.0.0-rc.78 > v1.0.0-rc.77 > ... (and v1.0.0 > v1.0.0-rc.N,
- # so a future final sorts above its rcs). pack-rust-vulns-*, backup/*
- # and rb* tags never match the v[0-9]* glob.
- PREV="$(git tag -l 'v[0-9]*' --sort=-v:refname | grep -vxF "${CURRENT}" | head -n1 || true)"
+ # The derivation lives in .github/scripts/prev_tag.sh so the code
+ # CI runs and the code under test are the same file: the
+ # version-successor of this cut among ^vX.Y.Z tags (an rc suffix
+ # counts — an rc is a real xerj release). pack-rust-vulns-*, backup/*
+ # and rb* never match. versionsort.suffix=-rc keeps a final vX.Y.Z
+ # above its own -rc.N — plain --sort=-v:refname does NOT, which
+ # would have pinned the first v1.0.1 cut to v1.0.0-rc.79 instead of
+ # v1.0.0. The self-test locks that ordering in before the output is
+ # trusted (and fails on a runner git too old for versionsort.suffix).
+ bash .github/scripts/prev_tag.sh --self-test
+ PREV="$(bash .github/scripts/prev_tag.sh "${CURRENT}")"
if [ -n "${PREV}" ]; then
echo "release-notes compare base: ${PREV}...${CURRENT}"
# Renders the notes without creating anything; previous_tag_name
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ba9cc0788..3400627a3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -233,6 +233,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
explicit `previous_tag_name`, falling back to auto-generation only when no
previous v-tag exists (PR
[#1069](https://github.com/xerj-org/xerj/pull/1069)).
+- **Release notes: the pinned compare base now orders a final above its own
+ rcs, and the derivation is fixture-tested.** The PR #1069 pin derived the
+ base with plain `--sort=-v:refname`, which orders `v1.0.0-rc.79` above
+ `v1.0.0` — the opposite of what that PR's message claims — so the first
+ `v1.0.1` cut would have compared against `v1.0.0-rc.79` rather than
+ `v1.0.0`, and re-dispatching an old tag would have compared against the
+ newest tag instead of that release's own predecessor. The derivation now
+ lives in `.github/scripts/prev_tag.sh`: `versionsort.suffix=-rc` puts a
+ prerelease below its final, the base is the version-successor of the tag
+ being cut, and a five-assertion fixture self-test (pack-tag noise,
+ `rc.9` created after `rc.78`, final among rcs, old-tag rebuild, first-ever
+ cut) runs in the release job before the base is trusted. Measured against
+ the live tag set on 2026-09-30: a hypothetical cut selects
+ `v1.0.0-rc.78`, while GitHub's auto-detection would anchor on
+ `pack-rust-vulns-2026-09-30`, published 10:47Z that morning (PR
+ [#1081](https://github.com/xerj-org/xerj/pull/1081)).
- **`benchmarks/ask-plan/` — the harness behind issue #1056's gate, shipped
before the endpoint so the gate is designed in the open**: 230 (prompt,
gold result set) pairs over three committed public tabular snapshots