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): cross-platform test harness and Windows file locking support (#1764)
Roedy Rustam9b02daa0f324
diff --git a/engine/crates/xerj-hub/src/flock.rs b/engine/crates/xerj-hub/src/flock.rsindex a592f0217..3f6e14016 100644--- a/engine/crates/xerj-hub/src/flock.rs+++ b/engine/crates/xerj-hub/src/flock.rs@@ -60,7 +60,7 @@ impl FileLock {loop {match file.try_lock() {Ok(()) => {- stamp(&file);+ stamp(&file, path);return Ok(FileLock {file,path: path.to_path_buf(),@@ -93,6 +93,10 @@ impl Drop for FileLock {// Closing the descriptor would release it too; unlocking first just makes// the hand-over immediate when the handle is kept alive by a clone.let _ = self.file.unlock();+ #[cfg(windows)]+ {+ let _ = fs::remove_file(companion_pid_path(&self.path));+ }}}@@ -126,16 +130,45 @@ fn open_lock_file(path: &Path) -> io::Result<File> {}}+#[cfg(windows)]+fn companion_pid_path(path: &Path) -> PathBuf {+ let mut os = path.as_os_str().to_os_string();+ os.push(".pid");+ PathBuf::from(os)+}+/// Record the holder's PID in the lock file. Best effort: it is a diagnostic.-fn stamp(file: &File) {- let _ = file.set_len(0);+fn stamp(file: &File, _path: &Path) {+ use std::io::Seek;let mut f = file;+ let _ = f.seek(std::io::SeekFrom::Start(0));+ let _ = file.set_len(0);let _ = writeln!(f, "{}", std::process::id());+ let _ = f.flush();+ #[cfg(windows)]+ {+ let pid_path = companion_pid_path(_path);+ let _ = fs::write(pid_path, format!("{}\n", std::process::id()));+ }}/// The PID last written into the lock file.fn read_holder(path: &Path) -> Option<u32> {- fs::read_to_string(path).ok()?.trim().parse().ok()+ if let Ok(s) = fs::read_to_string(path) {+ if let Ok(pid) = s.trim().parse() {+ return Some(pid);+ }+ }+ #[cfg(windows)]+ {+ let pid_path = companion_pid_path(path);+ if let Ok(s) = fs::read_to_string(pid_path) {+ if let Ok(pid) = s.trim().parse() {+ return Some(pid);+ }+ }+ }+ None}/// `" (held by pid N)"`, or nothing when the holder wrote no PID.diff --git a/engine/crates/xerj-hub/src/sync.rs b/engine/crates/xerj-hub/src/sync.rsindex dc570cb18..ab1f742bb 100644--- a/engine/crates/xerj-hub/src/sync.rs+++ b/engine/crates/xerj-hub/src/sync.rs@@ -872,7 +872,7 @@ impl TimerDirs {// XDG says a relative XDG_CONFIG_HOME is invalid and must be ignored.let config = env("XDG_CONFIG_HOME").map(PathBuf::from)- .filter(|p| p.is_absolute())+ .filter(|p| p.is_absolute() || p.has_root()).unwrap_or_else(|| home.join(".config"));Ok(TimerDirs {systemd_user: config.join("systemd").join("user"),diff --git a/tools/hub-packs/test_hub_packs.py b/tools/hub-packs/test_hub_packs.pyindex 05654b27e..3eaaf17cf 100644--- a/tools/hub-packs/test_hub_packs.py+++ b/tools/hub-packs/test_hub_packs.py@@ -33,7 +33,7 @@ SHA_C = "c" * 40def manifest_text(slug: str, repos: list[tuple[str, str, str]], extra: str = "") -> str:"""A manifest in the registry's own hand-formatted style (one repo per line)."""body = ",\n".join(- f' {{"repo":"{n}","url":"{u}","licence":"MIT","sha":"{s}","files":3,"bytes":99,'+ f' {{"repo":"{n}","url":"{u.replace(chr(92), "/")}","licence":"MIT","sha":"{s}","files":3,"bytes":99,'f'"review":{{"spdx":"MIT","use":"adapt-with-attribution","by":"xerj-org","at":"2026-08-12"}}}}'for n, u, s in repos)@@ -298,7 +298,7 @@ class RepinTests(unittest.TestCase):def test_ls_remote_reads_the_default_branch_head_of_a_real_repository(self):up, shas = make_upstream(self.root, "up")- url = f"file://{up}"+ url = f"file://{up.as_posix()}"self.assertEqual(hp.git_head_of(url, "file:https"), shas[-1])cs = self.corpora([("feed", "weekly", url, shas[0])])(p,), notes = hp.find_proposals(cs, hp.REPIN_CLASSES, lambda u: hp.git_head_of(u, "file:https"), "2026-10-14")@@ -311,7 +311,7 @@ class RepinTests(unittest.TestCase):def test_only_https_is_spoken_by_default(self):up, _ = make_upstream(self.root, "up")marker = self.root / "pwned"- self.assertIsNone(hp.git_head_of(f"file://{up}"), "file:// needs the test-only widening")+ self.assertIsNone(hp.git_head_of(f"file://{up.as_posix()}"), "file:// needs the test-only widening")self.assertIsNone(hp.git_head_of(f"ext::sh -c touch% {marker}"), "ext:: would run a command")self.assertIsNone(hp.git_head_of("git://example.test/r"))self.assertIsNone(hp.git_head_of(f"--upload-pack=touch {marker}"))@@ -330,7 +330,7 @@ class RepinTests(unittest.TestCase):self.assertFalse(marker.exists(), "GIT_ALLOW_PROTOCOL=https stops an ext:: URL from running anything")def test_a_dead_remote_is_none_not_an_exception(self):- self.assertIsNone(hp.git_head_of(f"file://{self.root}/nowhere", "file:https"))+ self.assertIsNone(hp.git_head_of(f"file://{self.root.as_posix()}/nowhere", "file:https"))GH_STUB = textwrap.dedent(@@ -386,9 +386,15 @@ class ApplyTests(unittest.TestCase):self.origin = originself.state = self.root / "gh-state.json"self.state.write_text(json.dumps({"calls": [], "prs": [], "next": 100}))- self.gh = self.root / "gh"- self.gh.write_text(GH_STUB.format(python=sys.executable, state=str(self.state)))- self.gh.chmod(0o755)+ if sys.platform == "win32":+ self.gh_py = self.root / "gh_stub.py"+ self.gh_py.write_text(GH_STUB.format(python=sys.executable, state=str(self.state)))+ self.gh = self.root / "gh.cmd"+ self.gh.write_text(f'@"{sys.executable}" "{self.gh_py}" %*\n')+ else:+ self.gh = self.root / "gh"+ self.gh.write_text(GH_STUB.format(python=sys.executable, state=str(self.state)))+ self.gh.chmod(0o755)def tearDown(self):self._tmp.cleanup()@@ -926,7 +932,7 @@ class CommandLineTests(unittest.TestCase):with tempfile.TemporaryDirectory() as t:root = pathlib.Path(t)up, shas = make_upstream(root, "up")- url = f"file://{up}"+ url = f"file://{up.as_posix()}"reg, backlog = write_registry(root, [row("feed", refresh="daily")], {"feed": manifest_text("feed", [("feed", url, shas[0])])})