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.
Rust agent-memoryai-agentsbm25claude-codeclicode-searchcursordatabaseelasticsearchfull-text-searchhybrid-searchjsonllocal-firstmcpmcp-servermodel-context-protocolragrustsearch-enginevector-search
ci(hub-packs): the delisting guard reads the live catalogue only if it is one (#1588)
xerj-org90ecb3c3612a
diff --git a/.github/workflows/hub-packs.yml b/.github/workflows/hub-packs.ymlindex 211e6aae6..8ca512703 100644--- a/.github/workflows/hub-packs.yml+++ b/.github/workflows/hub-packs.yml@@ -51,7 +51,10 @@# The catalogue job always builds, checks and uploads the signed catalogue as an# artifact. It deploys to Cloudflare Pages only when the repository VARIABLE# HUB_CATALOGUE_DEPLOY is "true" (a variable, not a secret): read the first-# artifact, then flip it. It uses the same Pages project and secrets as+# artifact, flip it, then DISPATCH this workflow on corpus-hub with+# first_catalogue=true. Before that, nothing valid is live, and the delisting+# guard (Check the catalogue) refuses to deploy over an unreadable catalogue;+# first_catalogue excuses only a missing one (404, or the site's HTML page). It uses the same Pages project and secrets as# deploy-hub-pages.yml, which replaces the whole site on every deploy, so the# two must not disagree about whether /api/v1/catalogue.json is part of it.#@@ -101,6 +104,10 @@ on:description: "Let the catalogue delist corpora that are still live (after a failed pack build)"type: booleandefault: false+ first_catalogue:+ description: "No signed catalogue is live yet: deploy without the delisting guard (the first deploy only)"+ type: boolean+ default: falserepin:description: "Also run the re-pin job now"type: boolean@@ -730,20 +737,61 @@ jobs:if: env.NO_PACKS != '1'env:ALLOW_DROPS: ${{ inputs.allow_drops }}+ FIRST_CATALOGUE: ${{ inputs.first_catalogue }}+ DEPLOYING: ${{ !inputs.dry_run && vars.HUB_CATALOGUE_DEPLOY == 'true' }}run: |set -euo pipefailbash tools/hub-packs/ed25519.sh verify "$HUB_PUBKEY_HEX" catalogue.json catalogue.json.sigargs=(check-catalogue --registry "$REGISTRY" --backlog "$BACKLOG" --catalogue catalogue.json \--repo "$GITHUB_REPOSITORY")- # Compare with the LIVE catalogue so a half-failed build cannot delist a corpus.- # Only a clean 404 means "first publish"; any other failure to read it must- # not quietly switch the guard off.- code=$(curl -sS --max-time 60 -o "$RUNNER_TEMP/live.json" -w '%{http_code}' \- "$HUB_URL/api/v1/catalogue.json" || echo 000)- case "$code" in- 200) args+=(--previous "$RUNNER_TEMP/live.json") ;;- 404) echo "no live catalogue yet (first publish)" ;;- *) echo "::error::cannot read the live catalogue (HTTP $code); not publishing without the delisting guard"; exit 1 ;;+ # Compare with the LIVE catalogue so a half-failed build cannot delist a+ # corpus. Only a clean 404 means "none yet". A 200 is a previous catalogue+ # only if it is one: signed by the hub key, and JSON with a corpora list.+ # (The site answers unknown paths with its HTML page and a 200; read as+ # JSON-or-nothing, that switched this guard off without a word.) Anything+ # else is UNKNOWN: fatal when this run deploys, unless the owner says this+ # is the first catalogue (first_catalogue); a warning otherwise, since+ # nothing is published.+ LIVE="$RUNNER_TEMP/live.json"+ # curl prints -w even when it fails: keep its code, note the failure.+ code=$(curl -sS --max-time 60 -o "$LIVE" -w '%{http_code}' \+ "$HUB_URL/api/v1/catalogue.json") || code="000 (curl exit $?)"+ sig_code=$(curl -sS --max-time 60 -o "$LIVE.sig" -w '%{http_code}' \+ "$HUB_URL/api/v1/catalogue.json.sig") || sig_code="000 (curl exit $?)"+ # `first_catalogue` may excuse only "nothing is there": a 404, or the+ # site's own HTML page in its place. A timeout, a 5xx or a JSON body+ # that fails its signature stays fatal even then.+ state=unknown; why="HTTP $code"; absent=false+ if [ "$code" = 404 ]; then+ state=none+ elif [ "$code" = 200 ]; then+ if [ "$(tr -d ' \t\r\n' < "$LIVE" | head -c 1)" != "{" ]; then+ absent=true+ why="200 but not JSON: $(head -c 40 "$LIVE" | tr -c '[:print:]' ' ') (the site's page, no catalogue)"+ elif [ "$sig_code" != 200 ]; then+ why="200 but its .sig is HTTP $sig_code (unsigned)"+ elif ! bash tools/hub-packs/ed25519.sh verify "$HUB_PUBKEY_HEX" "$LIVE" "$LIVE.sig" >/dev/null 2>&1; then+ why="200 but it does not verify under the hub key ($(head -c 40 "$LIVE" | tr -c '[:print:]' ' '))"+ elif ! jq -e '.corpora | type == "array"' "$LIVE" >/dev/null 2>&1; then+ why="200, signed, but not a catalogue"+ else+ state=live+ fi+ fi+ case "$state" in+ live) args+=(--previous "$LIVE"); echo "guarding against the live catalogue ($(jq '.corpora | length' "$LIVE") corpora)" ;;+ none) echo "no live catalogue yet (404): first publish" ;;+ unknown)+ msg="cannot read the live catalogue at $HUB_URL/api/v1/catalogue.json: $why"+ if [ "$FIRST_CATALOGUE" = "true" ] && [ "$absent" = "true" ]; then+ echo "::warning title=catalogue::$msg; first_catalogue is set, so publishing without the delisting guard"+ elif [ "$DEPLOYING" = "true" ]; then+ echo "::error title=catalogue::$msg; not deploying without the delisting guard. If no catalogue has ever been published, dispatch hub-packs on corpus-hub with first_catalogue=true (it excuses only a missing catalogue, not an unreadable one)."+ exit 1+ else+ echo "::warning title=catalogue::$msg; checked without the delisting guard (this run deploys nothing)"+ fi+ ;;esac[ "${ALLOW_DROPS:-}" = "true" ] && args+=(--allow-drops)python3 tools/hub-packs/hub_packs.py "${args[@]}"