Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Build the Rust extension in Claude Code web sessions

Claudebd00e62c3fcb
diff --git a/.claude/hooks/session-start.sh b/.claude/hooks/session-start.sh
new file mode 100755
index 0000000..11360ca
--- /dev/null
+++ b/.claude/hooks/session-start.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+# Claude Code on the web: install dependencies and build the Rust extension.
+set -euo pipefail
+
+if [ "${CLAUDE_CODE_REMOTE:-}" != "true" ]; then
+ exit 0
+fi
+
+cd "$CLAUDE_PROJECT_DIR"
+
+# xgboost_lib-sys's build script downloads a prebuilt libxgboost.so from
+# github.com/marcomq/rust-xgboost. The web session's GitHub proxy only serves the
+# session's own repositories, so the download comes back as a JSON error, which the
+# build script writes out as the library and linking then fails with "unknown file
+# type". The script skips the download when target/<profile>/deps already holds the
+# library, so seed it there from the xgboost-cpu wheel, pointing its RPATH at the
+# wheel's bundled libgomp.
+uv sync --group dev --no-install-project
+site_packages="$PWD/.venv/lib/python3.11/site-packages"
+for profile in debug release; do
+ deps="mwmbl_rank/target/$profile/deps"
+ mkdir -p "$deps"
+ cp "$site_packages/xgboost/lib/libxgboost.so" "$deps/"
+ .venv/bin/patchelf --set-rpath "$site_packages/xgboost_cpu.libs" "$deps/libxgboost.so"
+done
+
+uv sync --group dev
diff --git a/.claude/settings.json b/.claude/settings.json
new file mode 100644
index 0000000..d0d6eb3
--- /dev/null
+++ b/.claude/settings.json
@@ -0,0 +1,14 @@
+{
+ "hooks": {
+ "SessionStart": [
+ {
+ "hooks": [
+ {
+ "type": "command",
+ "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/session-start.sh"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/.gitignore b/.gitignore
index 33e0c85..5e0cd86 100644
--- a/.gitignore
+++ b/.gitignore
@@ -206,8 +206,10 @@ devdata/super_search_xgb/
# Claude issue automation writes and reads, stays tracked.
/plans/
-# Claude Code configuration
-.claude/
+# Claude Code configuration, apart from the shared settings and the web session hook
+.claude/*
+!.claude/settings.json
+!.claude/hooks/
# Pass-3 judging manifests and the Pass-2 per-source collection checkpoints. Both are
# resumable intermediates: once a checkpoint is merged, pass2_pool.jsonl holds everything it
# carried, and a manifest is only meaningful while its batch is out being judged.
diff --git a/AGENTS.md b/AGENTS.md
index be9dbbf..1e269f2 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -33,7 +33,11 @@ request, and `.pre-commit-config.yaml` runs the first of them on every commit.
`rankeval/` (ranking quality), `api.py` (django-ninja endpoints), `models.py`,
`settings_*.py` per environment.
- `mwmbl_rank/` — the Rust ranking extension, built with maturin. Changing it means
- `uv run maturin develop` before the tests will see it.
+ `uv run maturin develop` before the tests will see it. Its build downloads a prebuilt
+ `libxgboost.so` from GitHub, which Claude Code on the web cannot reach; there,
+ `.claude/hooks/session-start.sh` seeds the library from the `xgboost-cpu` wheel at
+ session start. If the build fails with `libxgboost.so: unknown file type`, rerun that
+ script rather than working around it by hand.
- `test/` — pytest suite, one file per area.
- `front-end/` — the JS build; leave it alone unless the change is about the UI.
- `scripts/`, `analyse/` — one-off analysis and evaluation tools, not application code.