返回 last30days-skill
README.md
根目录 / rust / README.md
1 # last30days-core (Native Rust Compute Core)
2
3 Built-in standalone native binary that powers the measured CPU hotspots of
4 `last30days-skill` by default:
5
6 - Parallel library Markdown privacy redaction, metadata parsing, and SHA-256 fingerprinting (`library.py`, `library_index.py`)
7 - Near-duplicate detection with 64-bit trigram/token fingerprints (`dedupe.py`)
8 - Greedy leader clustering, MMR representative selection, and cross-source entity merging (`cluster.py`, `entity_extract.py`)
9 - Token-overlap relevance and local signal annotation (`relevance.py`, `signals.py`, `cjk.py`)
10
11 ## Zero Rust required for end users
12
13 End users never install Rust, Cargo, or `rustup`.
14
15 - `setup` and the first live local run download the matching prebuilt binary
16 from GitHub Releases, verify its SHA-256 checksum against
17 `last30days-core-SHA256SUMS.txt` and its protocol handshake, and install it to
18 `~/.local/share/last30days/bin/last30days-core`.
19 - Linux binaries build statically against `musl`; macOS and Windows binaries
20 link only to standard OS libraries already present on every machine.
21 - They have no Python C-extension ABI coupling (one binary works across Python
22 3.12, 3.13, 3.14, and 3.15).
23 - Pure Python stays in place as an automatic fallback for offline sandboxes or
24 unsupported architectures, and `doctor` reports which backend is active.
25
26 ## Binary discovery
27
28 `rust_accel.py` checks, in order:
29
30 1. `LAST30DAYS_RUST_BIN` environment variable
31 2. `~/.local/share/last30days/bin/last30days-core` (`.exe` on Windows)
32 3. `<repo>/rust/target/release/last30days-core` (dev checkout)
33 4. `last30days-core` on `PATH`
34
35 ## A/B testing
36
37 ```bash
38 # Force pure Python
39 LAST30DAYS_ENGINE=python uv run python skills/last30days/scripts/last30days.py "topic" --quick
40
41 # Force Rust (fails fast if binary missing)
42 LAST30DAYS_ENGINE=rust uv run python skills/last30days/scripts/last30days.py "topic" --quick
43
44 # Override per-request worker timeout in seconds (default: 30)
45 LAST30DAYS_RUST_TIMEOUT=15 uv run python skills/last30days/scripts/last30days.py "topic" --quick
46
47 # Run full parity + speedup benchmark suite
48 uv run python scripts/bench_rust_vs_python.py
49 ```
50
51 ## Building from source
52
53 Requires stable Rust 1.85+ (no nightly features). Lint configuration follows
54 [BeautifulRust](https://github.com/morganlinton/BeautifulRust) (`clippy.toml`
55 and `[workspace.lints]` in `Cargo.toml`).
56
57 ```bash
58 cd rust
59 cargo fmt --check
60 cargo clippy --all-targets --all-features -- -D warnings
61 cargo test
62 RUSTDOCFLAGS="-D warnings" cargo doc --no-deps
63 cargo build --release
64 ```
65
66 See [PORTING.md](PORTING.md) for API mapping, test mapping, and preserved quirks.
67
67 lines MARKDOWN