Skip to content

chore(experiments): lab-only D-RST-3 borrowed pattern-CSR view (deferred, evidence only) - #4

Merged
AdaWorldAPI merged 2 commits into
masterfrom
ccr-08f48cec-lbv9l4
Oct 20, 2026
Merged

AdaWorldAPI merged 2 commits into
masterfrom
ccr-08f48cec-lbv9l4

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Adds experiments/relstore-visit, the D-RST-3 step of lance-graph's relstore-quack-petgraph-traversal-v1 plan (AdaWorldAPI/lance-graph#1622). It is an isolated crate with its own [workspace] and Rust 1.99, and it does not use the quarantined OutgoingHop. The default build has no lance-graph dependency. The quack feature pins lance-graph main fcd1f60e.

What it is

  • RelationStore::prepare builds a layout once: u32 offsets, u32 neighbour slots, u64 stable fact ids and the u32 source lane, ordered by (src, fact id). The store counts each preparation.
  • prepare_from_blasgraph_parts builds the same layout from BlasGraph CsrStorage's nrows, ncols, row_ptrs and col_indices. It has no values parameter, so the 2 KiB BitVecs cannot be passed in.
  • PatternCsr<'_> is a Copy view made of three borrowed slices and a version, so constructing one allocates nothing. Asking for any other version returns Stale. It implements GraphBase, GraphRef, IntoNeighbors, Visitable (FixedBitSet), NodeIndexable, NodeCount, NodeCompactIndexable, Data, IntoEdgeReferences and IntoEdges. EdgeId is the fact id; FactEdge::row() reports the physical row separately.
  • Refusals are returned, never silently dropped: OutOfDomain, DuplicateFact, Stale, TooLarge, MalformedCsr.
  • quack_hop::one_hop (feature quack): Quack lowers src == s, mask-risc executes it over the prepared src lane, and the neighbours are read from the prepared dst lane at the kept rows.

Tests

The oracle is a DiGraph built from the facts rather than from the layout; the view's BFS/DFS order must match it exactly.

  • Covers parallel edges, a self-loop, an isolated node, a one-way edge, empty relations and three random relations.
  • Also covers each refusal, and fact ids surviving both reordering and compaction while rows move.
  • The view's buffer pointers equal the prepared buffers. Building a view and walking every neighbour list allocate nothing.
  • With quack: the Quack hop gives the same neighbours as the view, reads the same dst buffer at the same version, and the store prepares once.

Seven disable runs (each guard removed alone) each failed their named test; the table is in the README.

Measurements (release, ranges over 3 runs; n 100k, m 1M)

  • View construction: 0.035 µs, 0 allocations.
  • Neighbour walk: 2.0 ns per edge for the view, 1.8–1.9 for Csr, 5.5–7.2 for DiGraph.
  • BFS: 6.8–12.9 ms for the view, 7.2–14.8 ms for Csr, 42–51 ms for DiGraph. The view allocates only petgraph's traversal state. One early run showed the view 2.7× faster than Csr; repeat runs did not reproduce it.
  • Prepare: 308–396 ns per edge. Measured, not optimized.
  • 64 one-hops: 14–18 ms through Quack vs 0.3 µs through the view. Quack scans the whole src lane for each query.

Open admission questions

  1. The Quack hop is O(E) because Quack cannot know that src is sorted. A sealed ordering witness (D-DIAMOND Cmp::Range) would make it a range read. That decision belongs to D-RST-1/2.
  2. RelationVersion and RelationStore are stand-ins until the store's LayoutSeal exists.
  3. Only out-edges are covered. IntoNeighborsDirected needs a reverse layout.
  4. BlasGraph is not a dependency (it pulls lance, datafusion and lancedb). The reuse is by signature, and the conversion from usize to u32 is a preparation, not a borrow.

Generated by Claude Code

experiments/relstore-visit is an isolated crate (own workspace, rust 1.99)
that prepares a relationship layout once (u32 offsets, u32 neighbour slots,
u64 stable fact ids, u32 source lane, ordered by (src, fact id)) and hands
out a Copy view, pinned to the version the buffers were prepared from. The
view implements the visit traits petgraph's Bfs and Dfs need, unmodified.

The edge id is the fact id; the physical row is reported separately and
moves on rebuild. Out-of-domain endpoints, duplicate fact ids, stale
versions and malformed BlasGraph parts are refused, never dropped.

Tests compare BFS/DFS orders against a DiGraph oracle built from the facts,
cover parallel edges, self-loops, isolated nodes and empty relations, and
check borrowed-buffer identity and zero allocations for the view and the
neighbour walk. The `quack` feature adds the shared-layout falsifier: a
Quack-compiled one-hop reads the same dst buffer at the same version, and
the store prepares once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VyWZYKycy6MoYDxHRVnV5K
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VyWZYKycy6MoYDxHRVnV5K
@AdaWorldAPI AdaWorldAPI changed the title D-RST-3: borrowed pattern-CSR view traversed by unmodified Bfs/Dfs [deferred, evidence only] D-RST-3: borrowed pattern-CSR view traversed by unmodified Bfs/Dfs Oct 20, 2026
@AdaWorldAPI AdaWorldAPI changed the title [deferred, evidence only] D-RST-3: borrowed pattern-CSR view traversed by unmodified Bfs/Dfs chore(experiments): lab-only D-RST-3 borrowed pattern-CSR view (deferred, evidence only) Oct 20, 2026
@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review October 20, 2026 08:19
@AdaWorldAPI
AdaWorldAPI merged commit e39ab5f into master Oct 20, 2026
15 of 17 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T08:20:00.044797Z 3dfc532 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

2 participants