Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,74 @@ on:
push:
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --check

clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- name: Native
run: cargo clippy --release --all-targets -- -D warnings
- name: WebAssembly
run: cargo clippy --release --target wasm32-unknown-unknown --all-targets -- -D warnings

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --release

wasm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
targets: wasm32-unknown-unknown
- run: rustup default stable
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with:
tool: wasm-pack
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Tests in Node
run: wasm-pack test --node --release
- name: Single-threaded and multithreaded builds
run: ./build.sh

audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@v2
with:
tool: cargo-audit
- run: cargo audit

attribution:
runs-on: ubuntu-latest
steps:
Expand Down
18 changes: 13 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,39 @@
- NEVER add `Co-Authored-By: Claude ...`, `noreply@anthropic.com`, "Generated with Claude Code"
or any other Claude / Anthropic attribution to commit messages, PR titles or PR descriptions.
This project was written by its author before Claude was involved. Plain commit messages only.
- This is enforced by `.githooks/commit-msg`. Enable it once per clone:
- This is enforced by `.githooks/commit-msg` and by CI. Enable the hook once per clone:
`git config core.hooksPath .githooks`
- Never bypass it with `--no-verify`.

## Project

Rust port of EigenTrust (go-eigentrust), runs natively and as WASM in the browser.
EigenTrust in Rust, runs natively and as WASM in the browser.

- `src/basic/engine.rs` - `calculate_from_csv`: CSV in, sorted `(peer, score)` out
- `src/basic/input.rs` - CSV reading (csv crate), header detection, weight validation
- `src/basic/eigentrust.rs` - power iteration (`compute`), runs on dense vectors
- `src/error.rs` - `Error` enum used everywhere; `Display` gives user-facing messages
- `src/sparse/` - CSR matrix / sparse vector
- `src/lib.rs` - wasm-bindgen entry `run(localtrust, pretrust, alpha)` (wasm32 only)
- `src/main.rs` - native CLI
- `src/main.rs` - native CLI, reports errors as `error: ...` with exit code 1
- `demo/` - static interactive web demo deployed to Vercel

## Commands

- Test: `cargo test --release`
- WASM tests: `wasm-pack test --node --release`
- Lint: `cargo fmt --check`, `cargo clippy --release --all-targets -- -D warnings`
(also with `--target wasm32-unknown-unknown`)
- CLI: `cargo run --release -- ./example/localtrust.csv ./example/pretrust.csv [alpha]`
- WASM: `./build.sh` (builds `pkg/` and copies it into `demo/pkg/`)
- WASM: `./build.sh` (builds `pkg/` and `pkg-parallel/` and copies them into `demo/`)
- Demo locally: `python3 -m http.server -d demo` then open http://localhost:8000
- Deploy: `vercel deploy --prod` from `demo/`

## Notes

- Tests compare floats with exact equality. The iteration uses Kahan-Babuska-Neumaier summation
in row order; keep the summation order if you touch `compute` / `mul_dense`.
- Duplicate `(i, j)` records in local trust: the last one wins.
- Duplicate `(i, j)` local trust records and duplicate pre-trust peers: the last one wins.
- Weights must be finite and non-negative. Distrust (negative weights) is rejected until its
effect on the scores is defined; `extract_distrust` / `discount_trust_vector` are kept for that.
- `compute` stops after `DEFAULT_MAX_ITERATIONS` (10,000) with `Error::NotConverged`.
Loading
Loading