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.

fix(hub-packs): match exact corpus when superseding proposals (#2100, from #2066)

xerj-org7ad28b6679b6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a9b08ac18..bc42d9d42 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -54,6 +54,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Hub pack planning reports malformed manifest JSON shapes as per-corpus warnings
and continues planning healthy corpora, rather than crashing on an invalid entry.
+- Hub re-pin automation only supersedes generated proposal branches for the
+ exact corpus, preserving proposals for corpora with longer overlapping names.
+
- `xerj search` and a plain-string `xerj_search` rank a file that contains
the query as an exact phrase (a pasted error message or log line) at the
top. The bag-of-words leg alone let a short `defs` list sharing two of the
diff --git a/tools/hub-packs/hub_packs.py b/tools/hub-packs/hub_packs.py
index 113ae55d5..2e89c7f0f 100644
--- a/tools/hub-packs/hub_packs.py
+++ b/tools/hub-packs/hub_packs.py
@@ -528,10 +528,10 @@ def apply_proposals(
open_prs = _gh_json(
gh, ["pr", "list", "--state", "open", "--limit", "200", "--json", "number,headRefName"], repo_root
) or []
- mine = f"{BRANCH_PREFIX}{p.slug}-"
+ mine = re.compile(re.escape(f"{BRANCH_PREFIX}{p.slug}-") + r"[0-9a-f]{8}")
for other in open_prs:
head = other["headRefName"]
- if head.startswith(mine) and head != p.branch:
+ if mine.fullmatch(head) and head != p.branch:
_run(
[gh, "pr", "close", str(other["number"]), "--delete-branch", "--comment", f"Superseded by {url}"],
cwd=repo_root,
diff --git a/tools/hub-packs/test_hub_packs.py b/tools/hub-packs/test_hub_packs.py
index ee93ea108..110aab8cd 100644
--- a/tools/hub-packs/test_hub_packs.py
+++ b/tools/hub-packs/test_hub_packs.py
@@ -512,6 +512,24 @@ class ApplyTests(unittest.TestCase):
open_heads = [p["headRefName"] for p in self.gh_state()["prs"] if p["state"] == "OPEN"]
self.assertEqual(open_heads, [new.branch])
+ def test_superseding_a_corpus_preserves_longer_slug_branches(self):
+ (proposal,) = self.proposals(["feed"])
+ st = self.gh_state()
+ st["prs"] = [
+ {"number": 91, "state": "OPEN", "headRefName": "hub-repin/feed-12345678"},
+ {"number": 92, "state": "OPEN", "headRefName": "hub-repin/feed-extra-12345678"},
+ {"number": 93, "state": "OPEN", "headRefName": "hub-repin/feed-manual-review"},
+ ]
+ self.state.write_text(json.dumps(st))
+ _, failures = self.apply([proposal])
+ self.assertEqual(failures, 0)
+ by_number = {p["number"]: p["state"] for p in self.gh_state()["prs"]}
+ self.assertEqual(by_number[91], "CLOSED", "an older exact-corpus proposal is superseded")
+ self.assertEqual(by_number[92], "OPEN", "a longer corpus slug is independently owned")
+ self.assertEqual(by_number[93], "OPEN", "non-generated branch suffixes are not ours")
+ closes = [c[2] for c in self.gh_state()["calls"] if c[:2] == ["pr", "close"]]
+ self.assertEqual(closes, ["91"])
+
def test_one_failure_does_not_stop_the_rest(self):
first, second = self.proposals()
st = self.gh_state()