Skip to content

Input validation, typed errors, real CSV, stricter CI, license - #16

Merged
hypnagonia merged 4 commits into
mainfrom
correctness-and-ci
Sep 30, 2026
Merged

hypnagonia merged 4 commits into
mainfrom
correctness-and-ci

Conversation

@hypnagonia

Copy link
Copy Markdown
Owner

Addresses the review:

  • Duplicate pre-trust: the last value wins, and to_dense adds repeated indices. Scores always sum to 1.
  • NaN / infinity: rejected at parse time with file and line; NaN guard in the iteration.
  • alpha = 0: iterations capped at 10,000, returns a clear "did not converge" error instead of looping forever.
  • Distrust: negative weights are rejected until their effect is defined; the unused discount step is off the engine path.
  • CSV: the csv crate handles quotes, embedded commas and escaped quotes; correct line numbers; same speed.
  • Errors: Error enum instead of String; the CLI prints error: ... and exits 1, no expect; output is proper CSV.
  • Cleanup: stale code and resolved todos removed; cargo fmt and clippy clean on native and wasm32.
  • CI: fmt, clippy (native + wasm32), native tests, wasm tests in Node, both WASM builds, cargo audit (fixed RUSTSEC-2026-0204 in crossbeam-epoch).
  • License: MIT OR Apache-2.0.
  • Playground: quote-aware CSV, engine errors are now visible.

Results are unchanged on valid input (bit-identical on a 100k-peer benchmark).

Correctness
- duplicate pre-trust peers: the last value wins (same as local trust);
  before, duplicates were normalized separately and then collapsed by
  to_dense, so pre-trust and the scores could stop summing to 1
- Vector::to_dense adds repeated indices instead of overwriting them
- weights must be finite and non-negative; NaN/inf are rejected with the
  line number instead of spinning forever
- negative weights (distrust) are rejected until their effect on the
  scores is defined; the unused discount step is off the engine path
- compute() caps iterations at 10,000 (alpha = 0 on a periodic graph
  used to loop forever) and guards against non-finite deltas
- flat tail check compares only the top num_leaders peers

Robustness and cleanup
- Error enum with file, line and reason instead of String errors
- CSV read with the csv crate: quotes, embedded commas, escaped quotes;
  line numbers stay correct across blank lines; same speed as before
- CLI: usage message, error: ... with exit code 1, no expect/unwrap,
  CSV-quoted output, quiet on a closed pipe
- wasm-bindgen tests for run(); start function renamed from main
- removed ConvergenceChecker, duplicate canonicalize, stale wrappers
  and resolved todos; cargo fmt and clippy clean on native and wasm32
- crossbeam-epoch 0.9.21 (RUSTSEC-2026-0204)
- Cargo.toml license field
- CSV tab parses and writes quoted fields the same way as the engine
- engine errors (e.g. alpha 0 on a periodic network) are shown under
  the ranking; before they were overwritten right away
@hypnagonia
hypnagonia merged commit a412663 into main Sep 30, 2026
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant