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
fix(hub-packs): check-catalogue refuses a previous catalogue that is not one (#1582)
xerj-org37ac48f68370
diff --git a/tools/hub-packs/hub_packs.py b/tools/hub-packs/hub_packs.pyindex 451168052..25d4c7473 100644--- a/tools/hub-packs/hub_packs.py+++ b/tools/hub-packs/hub_packs.py@@ -611,10 +611,19 @@ def check_catalogue(errors.append(f"{slug}: pack_bytes is not a positive integer")if previous is not None:+ # The guard must never switch itself off: a "previous catalogue" that is+ # not one (a static site's HTML page answering with 200, say) is an error,+ # not an empty list of corpora.+ before_list = Nonetry:- before = {x.get("slug") for x in json.loads(previous).get("corpora", [])}- except (json.JSONDecodeError, AttributeError):- before = set()+ prev = json.loads(previous)+ if isinstance(prev, dict) and isinstance(prev.get("corpora"), list):+ before_list = prev["corpora"]+ except (json.JSONDecodeError, UnicodeDecodeError):+ pass+ if before_list is None or not all(isinstance(x, dict) for x in before_list):+ return [*errors, "the previous (live) catalogue is not a catalogue; cannot tell which corpora it lists"]+ before = {x.get("slug") for x in before_list}for slug in sorted((before & set(live)) - listed):errors.append(f"{slug}: in the live catalogue and still live, but missing from the new one")return errorsdiff --git a/tools/hub-packs/test_hub_packs.py b/tools/hub-packs/test_hub_packs.pyindex 4c83ba81b..a4c48e6cb 100644--- a/tools/hub-packs/test_hub_packs.py+++ b/tools/hub-packs/test_hub_packs.py@@ -592,6 +592,13 @@ class CatalogueTests(unittest.TestCase):self.assertEqual(errors, ["beta: in the live catalogue and still live, but missing from the new one"])self.assertEqual(self.check(live, previous=live), [])+ def test_a_previous_catalogue_that_is_not_one_never_switches_the_guard_off(self):+ raw = self.cat(self.entry("alpha", SHA_A))+ for prev in (b"<!doctype html><html><body>hub</body></html>", b"", b"[]", b'{"corpora": "x"}',+ b'{"corpora": [1]}', b"\xff\xfe"):+ errors = self.check(raw, previous=prev)+ self.assertTrue(any("not a catalogue" in e for e in errors), (prev, errors))+def test_a_corpus_that_is_no_longer_live_may_leave_the_catalogue(self):previous = self.cat(self.entry("alpha", SHA_A), self.entry("retired", SHA_C))raw = self.cat(self.entry("alpha", SHA_A))@@ -621,6 +628,11 @@ class CatalogueTests(unittest.TestCase):self.assertIn("NOT fit to publish", refused.stderr)self.assertEqual(run("--previous", str(live_path), "--allow-drops").returncode, 0, "the explicit override")+ live_path.write_text("<!doctype html><html></html>")+ html = run("--previous", str(live_path), "--allow-drops")+ self.assertEqual(html.returncode, 1, "--allow-drops does not excuse an unreadable live catalogue")+ self.assertIn("not a catalogue", html.stderr)+def test_fetch_list_command_prints_tab_separated_rows(self):tags = self.root / "tags.txt"tags.write_text("pack-alpha-aaaaaaaa-r2\n")