Skip to content

contract: ClassView::menu_address — the runtime Klickwege radix projection#678

Merged
AdaWorldAPI merged 1 commit into
mainfrom
claude/medcare-ruff-codebook-handover-5ulx0i
Jul 11, 2026
Merged

contract: ClassView::menu_address — the runtime Klickwege radix projection#678
AdaWorldAPI merged 1 commit into
mainfrom
claude/medcare-ruff-codebook-handover-5ulx0i

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

The "ClassView after" half of the digest-now-ClassView-after plan. ruff #82 lowered the Klickwege menu quad's location into the classid radix trie in the nav_digest [menu-quad] section; this is the runtime twin.

Adds ClassView::menu_address(class) -> Vec<ClassId> — a default 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 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").

  • Reuses the exact cycle/depth guard of the sibling resolve_render_class (16-hop cap + on-stack visited array; never loops, never panics; the only allocation is the returned path).
  • Default method → every existing ClassView impl gains it for free; no new type or module, pure additive trait surface.

Test Plan

  • menu_address_walks_is_a_root_first30 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-contract green; clippy clean; LATEST_STATE.md Contract Inventory prepended in the same commit (board-hygiene rule).

🤖 Generated with Claude Code


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Added class menu address calculation based on root-first ancestry.
    • Added safeguards to prevent excessive traversal and handle circular hierarchies.
  • Bug Fixes

    • Improved reliability when processing self-referential or cyclic class relationships.
  • Tests

    • Added coverage for linear ancestry paths and cycle termination.

…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.
@cursor

cursor Bot commented Jul 11, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a default ClassView::menu_address method that returns bounded, cycle-safe, root-first ancestry paths. Tests cover linear inheritance, self-loops, and cycles, while the contract inventory documents the new projection.

Changes

Menu address projection

Layer / File(s) Summary
Bounded ancestry path computation
crates/lance-graph-contract/src/class_view.rs, .claude/board/LATEST_STATE.md
menu_address walks is_a_parent with a 16-hop cap and cycle detection, reverses results to root-first order, and adds tests for linear and cyclic ancestry. The contract inventory documents the method and its rendering assumptions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

A bunny hops up the class-tree line,
Root before leaf, the path looks fine.
Sixteen steps, no loops to fear,
Self-loops stop when they reappear.
Menu paths bloom—hop, hop, hooray!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly names the added ClassView::menu_address method and its radix-style runtime projection behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AdaWorldAPI AdaWorldAPI merged commit 81a5068 into main Jul 11, 2026
6 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
crates/lance-graph-contract/src/class_view.rs (1)

1641-1668: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider 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_class has resolve_render_class_depth_cap_returns_original for 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

📥 Commits

Reviewing files that changed from the base of the PR and between a724c5c and d23d963.

📒 Files selected for processing (2)
  • .claude/board/LATEST_STATE.md
  • crates/lance-graph-contract/src/class_view.rs

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