contract: ClassView::menu_address — the runtime Klickwege radix projection#678
Conversation
…ction The "ClassView after" half of digest-now-ClassView-after. ruff #82 lowered the menu quad's location into the classid radix trie in the nav_digest [menu-quad] section; this is the RUNTIME twin: a default ClassView trait method that walks is_a_parent root-first to build a class's menu address `[root, …, parent, class]` — a path through the existing concept ontology (the ontology IS the radix trie), never a stored ordinal (V3 LE-contract §3). A renderer lays out the menu by prefix from the path alone, zero value decode. Reuses the exact cycle/depth guard of the sibling resolve_render_class (16-hop cap + on-stack visited array; never loops, never panics; only alloc is the returned path). Default method → every ClassView impl gains it for free. Tests: menu_address_walks_is_a_root_first (30 is_a 20 is_a 7 -> [7,20,30]; root -> [7]); menu_address_cycle_terminates (2-cycle + self-loop bounded). Board: LATEST_STATE Contract Inventory prepended (same commit, per hygiene rule). lance-graph-contract green; clippy clean.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_24a47e41-656d-4969-9fc7-b9240a24f730) |
📝 WalkthroughWalkthroughAdds a default ChangesMenu address projection
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/lance-graph-contract/src/class_view.rs (1)
1641-1668: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider adding a depth-cap test for
menu_address.The existing tests cover linear chains, root classes, 2-cycles, and self-loops, but don't exercise the 16-hop depth cap.
resolve_render_classhasresolve_render_class_depth_cap_returns_originalfor the same guard — a sibling test here would verify the path truncates at 17 elements (16 hops) and stays root-first.🧪 Suggested depth-cap test
+ /// A chain exceeding the 16-hop cap truncates the path at 17 elements, + /// still root-first (same cap as `resolve_render_class`). + #[test] + fn menu_address_depth_cap_truncates_path() { + // 200 is_a 201 is_a ... is_a 220 — 21 classes, 20 edges. + let mut classes = FakeClasses::new(); + for c in 200u16..220 { + classes = classes.with_isa(c, c + 1); + } + let addr = classes.menu_address(200); + // 16 hops allowed → 17 elements in the path (200 through 216). + assert_eq!(addr.len(), 17, "depth cap truncates at 17 elements (16 hops)"); + // Root-first: the deepest reachable ancestor is first. + assert_eq!(addr[0], 216); + assert_eq!(addr[16], 200); + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/lance-graph-contract/src/class_view.rs` around lines 1641 - 1668, Add a sibling test for FakeClasses::menu_address that builds a chain exceeding the 16-hop guard, then asserts the result is truncated to 17 root-first class IDs and does not loop. Mirror the depth-cap expectations covered by resolve_render_class_depth_cap_returns_original while preserving the existing cycle and root behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/lance-graph-contract/src/class_view.rs`:
- Around line 1641-1668: Add a sibling test for FakeClasses::menu_address that
builds a chain exceeding the 16-hop guard, then asserts the result is truncated
to 17 root-first class IDs and does not loop. Mirror the depth-cap expectations
covered by resolve_render_class_depth_cap_returns_original while preserving the
existing cycle and root behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: fffde44f-5bf8-4d23-9d42-c6a576defd13
📒 Files selected for processing (2)
.claude/board/LATEST_STATE.mdcrates/lance-graph-contract/src/class_view.rs
Summary
The "ClassView after" half of the digest-now-ClassView-after plan. ruff #82 lowered the Klickwege menu quad's
locationinto the classid radix trie in thenav_digest[menu-quad]section; this is the runtime twin.Adds
ClassView::menu_address(class) -> Vec<ClassId>— a default trait method that walksis_a_parentroot-first to build a class's menu address[root, …, parent, class]: a path through the existing concept ontology (the ontology is the radix trie), never a stored ordinal (V3 LE-contract §3 forbids a position slot). A renderer lays out the menu by prefix from the path alone, with zero value decode (OGAR "the key prerenders nodes").resolve_render_class(16-hop cap + on-stack visited array; never loops, never panics; the only allocation is the returned path).ClassViewimpl gains it for free; no new type or module, pure additive trait surface.Test Plan
menu_address_walks_is_a_root_first—30 is_a 20 is_a 7→[7, 20, 30]; a root class →[7].menu_address_cycle_terminates— a 2-cycle stops at the first repeat ([41, 40]); a self-loop →[50].lance-graph-contractgreen; clippy clean;LATEST_STATE.mdContract Inventory prepended in the same commit (board-hygiene rule).🤖 Generated with Claude Code
Generated by Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests