ruflo neural train crashes with libc++abi mutex lock failed on macOS arm64 (GitHub Actions macos-latest)
- Dominant language
- TypeScript
- Stars
- 72.7k
- Forks
- 8.6k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 83
Description
`ruflo neural train` crashes with `libc++abi: mutex lock failed: Invalid argument` on macOS arm64 (GitHub Actions `macos-latest`)
## Summary
`ruflo neural train -p coordination -e 50` reliably crashes the Node process on `macos-latest` GitHub Actions runners (Apple Silicon) with an uncaught C++ exception, right after the embedding model loads. Reproduced across 2 consecutive nightly runs (2026-07-30, 2026-07-31) in [pacphi/agentic-kit](https://github.com/pacphi/agentic-kit)'s `nightly-live` canary workflow, which installs `ruflo@latest` fresh each night specifically to catch this kind of upstream regression.
## Environment
- `ruflo 3.33.0` (latest at time of failure)
- `agentic-qe 3.13.3`
- Node `22.23.1` (arm64), via `actions/setup-node@v7`
- Runner: GitHub Actions `macos-latest` (Apple Silicon)
- Global install: `npm install -g --allow-scripts=ruflo,agentic-qe,@claude-flow/cli,better-sqlite3,hnswlib-node,agentdb,agentic-flow,argon2,onnxruntime-node,sharp,protobufjs,@google/genai,tldjs,vibium ruflo@latest agentic-qe@latest`
## Steps to reproduce
```bash
npm install -g --allow-scripts=ruflo,agentic-qe,@claude-flow/cli,better-sqlite3,hnswlib-node,agentdb,agentic-flow,argon2,onnxruntime-node,sharp,protobufjs,@google/genai,tldjs,vibium ruflo@latest agentic-qe@latest
mkdir /tmp/repro && cd /tmp/repro
ruflo neural train -p coordination -e 50
```
## Observed output
```
learning — train a cycle in an isolated dir, assert patterns persist
[ruvector] WASM backend unavailable (Cannot find module '@ruvector/learning-wasm/ruvector_learning_wasm_bg.wasm'
Require stack:
- .../ruflo/node_modules/@claude-flow/cli/dist/src/services/ruvector-training.js), using JS fallback
✅ Using native better-sqlite3
dtype not specified for "model". Using the default dtype (fp32) for this device (cpu).
libc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument
```
Process exits non-zero immediately after that abort — no patterns/stats are written to `.claude-flow/neural/`.
## Notes
- The crash happens specifically with **native `better-sqlite3`** loaded alongside the transformers.js/onnxruntime embedding path (`Xenova/all-MiniLM-L6-v2`, CPU backend, invoked as the fallback once `@ruvector/learning-wasm`'s `.wasm` file isn't resolved — see the "WASM backend unavailable" line above, which may be a separate but related packaging issue: the `.wasm` asset doesn't appear to ship/resolve correctly).
- A separate local repro (Apple Silicon, non-CI) where the native `better-sqlite3` build was unavailable and the SQLite backend fell back to `sql.js` (WASM) instead did **not** crash — same `ruflo@3.33.0`, same host arch. That points at a thread-safety/mutex-reinit issue when both native addons (better-sqlite3 + onnxruntime-node) are loaded in the same process on this platform, rather than a pure onnxruntime issue in isolation.
- `live (ubuntu-latest)` passed on the same commit/run, so this looks macOS-arm64-specific.
- CI run showing the failure with this exact trace: https://github.com/pacphi/agentic-kit/actions/runs/30613986990/job/91102855478
- Prior occurrence (before better diagnostics were in place, only "ruflo neural train failed" with no detail): https://github.com/pacphi/agentic-kit/actions/runs/30612324523
Happy to provide more detail or test a fix candidate — this is caught nightly by an upstream-drift canary so we'll see immediately if a future release resolves it.
Contributor guide
Research direction
Start by running `ruflo neural train -p coordination -e 50` on a `macos-latest` arm64 runner using the installation command in the report. Inspect `ruflo/node_modules/@claude-flow/cli/dist/src/services/ruvector-training.js` and the native `better-sqlite3` and `onnxruntime-node` loading path around the reported crash. Done means training exits successfully and writes patterns or stats to `.claude-flow/neural/` without the mutex abort.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, node.js, sqlite, typescript
- Domain
- backend, ci-cd, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100