Repository navigation
Optimize exact mincut, routing and RuField spatial awareness across Rust, Node and WASM - #986
Merged
Merged
Conversation
…stale canonical caches
ruvnet
marked this pull request as ready for review
September 15, 2026 22:05
…heaps; validate real graph runtimes
… bounded WASM workers
…ch Rustls advisory
ruvnet
added a commit
that referenced
this pull request
Sep 16, 2026
…fixes) (#987) Manually applies the version bumps from dependabot PRs #975 and #957, which couldn't be cleanly rebased (dependabot didn't respond to @dependabot rebase, and both showed CONFLICTING after #986/#980/#944/#981 touched the same lockfile). Only the two resolved-package entries changed in package-lock.json; neither is a direct dependency. hono 4.13.1->4.13.7 fixes: XSS via unescaped strings in hono/jsx boundary components (GHSA-hxh3-vqpv-xpqv), SSRF/cache-key confusion in query parsing past URL fragments, an incomplete-fix follow-up for toSSG() path traversal (CVE-2026-39408), and memory exhaustion via unbounded dot-notation in parseBody(). fast-uri 3.1.4->3.1.7 fixes: authority injection via unvalidated port in serialize(), host confusion via malformed IP-literal brackets, SSRF via repeated hostname percent-decoding and malformed IPv6 normalization, and host confusion via percent-encoded scheme normalization. Closes #975, #957. Claude-Session: https://claude.ai/code/session_01SjxUvZnyBdwtx4Y1jKAqt6
ruvnet
added a commit
that referenced
this pull request
Sep 16, 2026
…rtifacts (#990) Publishing the PR #986 mincut work (exact Stoer-Wagner, directed routing, RuField) surfaced three blockers. 1. ruvector-mincut-node and ruvector-mincut-wasm pinned `ruvector-mincut = "2.0"`. At publish time cargo strips the path dep, so that caret range resolves to the published 2.0.6 -- the OLD spanning-tree heuristic that #986 replaced because it is not exact. The bindings would have shipped built against the bug they were meant to fix. Now "2.3". 2. ruvector-graph-condense, ruvector-graph-condense-wasm and ruvector-perception pinned `ruvector-mincut = "2.2.3"`, a version that was never published (crates.io max is 2.0.6) and never will be (workspace is 2.3.0). Now "2.3". 3. npm/packages/mincut-wasm declared main/types/exports/files over node/ and web/ directories that did not exist in git, and no workflow builds them, so `npm publish` could not produce a working package. Both targets are now built with wasm-pack and committed. The wasm-pack-generated .gitignore in each output dir is deliberately removed: npm honours it, and with it in place the tarball shipped 5 files (4 kB, no wasm at all) instead of 17 (386 kB). Verified: cargo check passes for both bindings against the 2.3 pin; the npm package's own prepack gate passes; 9/9 package tests pass against the real artifacts; and a tarball installed into a clean project computes the exact min cut (6) and a directed route (cost 20) end to end.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RuField spatial awareness follow up (September 16, 2026)
Integrated RuView RuField events with the exact directed road router across Rust, native Node, WASM and the npm worker API.
Key behavior:
Validated at a55d429:
Trust boundary: this consumer intentionally does not reimplement RuField Ed25519 trust registry and replay policy. Hosts must set verified=true only after RuField TrustVerifier accepts the receipt. Signature shaped JSON alone is never considered proof.
README files remain unchanged. No merge or npm publication was performed.
Map and routing follow-up (September 15, 2026)
Added a separate exact directed road-routing engine alongside the undirected mincut engine. The routing API supports stable arc IDs, parallel arcs, integer costs, consecutive-arc turn prohibitions, closures and atomic cost updates. Compressed adjacency, reusable query scratch, an indexed heap and directed landmark A* accelerate repeated queries. Closures and increases preserve admissible landmark bounds; decreases and reopening discard them. Geographic nearest-vertex lookup uses a balanced 3D k-d tree on spherical coordinates, including poles and the date line.
Node exposes RoadRouter and WASM exposes WasmRoadRouter. The npm ./routing export provides a dedicated WASM worker in Node and browsers, typed declarations, a bounded request queue, timeouts and cancellation. Aborting an in-flight request terminates that worker and rejects all its pending operations. Graph inputs, scalar IDs, integer costs, coordinate ranges, batch lengths and work budgets are validated. Shared input buffers are rejected by the worker client. Query heaps contain at most one entry per state.
Reproducible validation:
Paired kernel results at 2670867, uniform endpoints (milliseconds):
Landmark preprocessing: NY 583.0 ms, BAY 654.3 ms. Local-query geometric-mean improvements are 1.84x and 1.60x, but 5/64 NY and 15/64 BAY local pairs regress by more than 10%, mostly at microsecond/sub-microsecond scales. No sampled uniform pair regressed by more than 10%. These comparisons establish improvement over this Dijkstra baseline, not superiority over CCH, OSRM, GraphHopper or routing SOTA.
Map lookup: 256 slightly offset real-node queries per graph, exact agreement with a linear scan using precomputed spherical coordinates. Mean indexed time: NY 1.09 microseconds, BAY 1.26 microseconds; scan means 593.08 and 716.58 microseconds. Spatial construction time is reported separately.
Complete API uniform-route timing, including returned arrays and worker messaging:
Evidence:
Security review:
Practical limits: these historical DIMACS graphs have known map gaps and contain no current OSM access policy. This API consumes normalized directed graphs; an OSM importer must resolve access, conditional and complex via-way rules before construction. The native turn model prohibits consecutive arc pairs. Geographic snapping returns the nearest vertex, not a point along an edge. We have not built a live navigation service, map renderer, turn-by-turn instructions, or a competing SOTA routing-engine baseline. Longer-term acceleration and current OSM integration remain separate work.
README files remain unchanged. PR is open for review; no merge or npm publication was performed.
Real-data optimization follow-up (September 15, 2026)
Implemented linear-time structural certificates and an indexed maximum-adjacency heap in the exact kernel. For a connected simple weighted graph, every cut is either a bridge or contains at least two edges. Therefore the cut value is at least min(lightest bridge, twice the lightest edge). A bridge or singleton partition is returned early only when it meets that bound. All other inputs still use the exact contraction solver. The iterative DFS avoids native and WASM stack overflow; heap updates retain only one entry per active vertex.
Added explicit Node clear() to release graph allocations and cached state without waiting for JavaScript garbage collection, while retaining solver configuration.
Data and methodology:
Verified paired kernel and runtime run, kernel code unchanged by the subsequent Node clear() addition:
Kernel process peak RSS on the Facebook largest component fell from 12,544 KiB to 9,624 KiB, about 23%. These measurements include the benchmark process and input storage, not just heap entries. The indexed heap alone has O(n) entries instead of accumulating O(m) stale entries. Total graph storage remains O(n+m).
Validation:
Acceptance: rerun MinCut regression and MinCut real data. All optimized cases must complete and every checked value/partition must agree with the igraph oracle; baseline timeouts remain visible. Review the dense-core rows separately from certificate fast paths.
Latest head e23dc31:
Earlier implementation and synthetic benchmark evidence
The public dynamic solver could return a cut value without a matching partition, reuse stale canonical results, and spend time maintaining structures that were not supplying a correct global cut. WASM batches also solved after every edge, and weight replacement could remove an edge before rejecting its replacement.
This PR improves the implementation and JavaScript distribution. README files are unchanged.
Changes:
Compatibility:
Research assessment:
Validation at 93fdf5e:
Measured release-mode medians on the same GitHub runner, 40 vertices, 780 edges, five repetitions after warmup:
Both paths assert the same final exact cut value. These are synthetic batch-construction measurements, not universal speedup or latency guarantees. New batches reduce both boundary crossings and intermediate solves. The generated WASM binary is 352,870 bytes; the npm tarball containing both Node and web distributions is 257.3 kB.
Reproduce after building bindings using npm/packages/mincut-wasm/bench/batch.cjs. The workflow builds bindings and generates matching wasm-bindgen glue automatically, runs the benchmark, packs the package, and tests installation. The public Rust benchmark now compares against the previously verified c92142b revision; the original repository implementation can fail nondeterministically with duplicate-edge errors during its benchmark. The historical original-base comparison remains available in the earlier validated run.
The package is prepared for review, not published. Existing dependency security findings are not suppressed or bundled into this focused patch.