Skip to content

contract: un-gate mint_for + default-on guid-v3-tail; route ocr/aiwar mints#663

Open
AdaWorldAPI wants to merge 1 commit into
mainfrom
claude/v3-substrate-migration-review-o0yoxv
Open

contract: un-gate mint_for + default-on guid-v3-tail; route ocr/aiwar mints#663
AdaWorldAPI wants to merge 1 commit into
mainfrom
claude/v3-substrate-migration-review-o0yoxv

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Jul 7, 2026

Copy link
Copy Markdown
Owner

What

Executes the structural half of ISS-V1-TAIL-RESIDUE (operator ruling 2026-07-04: "default-on guid-v3-tail now so production mints route through mint_for in every build").

Changes

  • canonical_node.rsmint_for moved to an unconditional impl NodeGuid: V1 arm always available; V2/V3 arms feature-gated (guid-v2-tail) with a dead V1 fallback so --no-default-features still compiles.
  • lance-graph-contract/Cargo.tomldefault = ["guid-v3-tail"]. Every normal build has the V3 mint path.
  • ocr.rs + aiwar.rs — route through mint_for(classid_read_mode(c).tail_variant, …) instead of hardcoded NodeGuid::new. ocr is classid-param-driven (V3-ready); aiwar stays on the V1 CLASSID_OSINT (behavior-preserving — see below).
  • .claude/commands/v3-audit.md — check feat(graph): add SPO triple store with bitmap ANN, TruthGate, semirin… #6 forbids NodeGuid::new( in non-test production code (the mechanical guard the issue asked for).
  • .claude/board/ISSUES.md — progress + the newly-discovered blocker.

Discovered blocker (deferred, documented)

Flipping aiwar to CLASSID_OSINT_V3 (a real V3 mint) broke aiwar::tests::projects_to_family_node_graph: the V3 tail lays family at bytes 12..14 (u16), but soa_graph::project_snapshot reads it via the V1 family() u24 accessor (bytes 10..13) → family grouping reads leaf-dominated garbage. So aiwar's V3-classid flip is now gated on making that consumer tail-aware (an I-LEGACY-API-FEATURE-GATED consumer migration), not on the feature gate the original issue named. Once CLASSID_OSINT's registry tail_variant flips, the aiwar mint auto-follows through mint_for.

Verification

  • 854 contract lib tests green (default build, guid-v3-tail on).
  • --no-default-features compiles (the un-gate's purpose).
  • lance-graph + lance-graph-planner check clean — the default-on flip propagates safely to consumers.
  • cargo fmt + cargo clippy -p lance-graph-contract clean.

Remaining (still open in ISS-V1-TAIL-RESIDUE)

  1. Make project_snapshot / OSINT_GOTHAM read family tail-aware.
  2. Then flip CLASSID_OSINT's registry tail_variant (or point aiwar/ocr at a V3-marked classid). ocr is already V3-ready.

🤖 Generated with Claude Code


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Tail-aware GUID minting is now enabled by default for graph contracts.
    • Production node creation now follows the registered class layout automatically.
  • Bug Fixes

    • Reduced reliance on hardcoded node ID construction in key creation paths.
    • Added an audit check to catch outdated node minting patterns in production code.
    • Improved compatibility handling so existing V1 behavior still works where needed.

… mints

Executes the structural half of ISS-V1-TAIL-RESIDUE (operator ruling
2026-07-04, "default-on guid-v3-tail now so production mints route through
mint_for in every build").

- canonical_node.rs: `mint_for` moved to an unconditional `impl NodeGuid` —
  V1 arm always available; V2/V3 arms feature-gated (`guid-v2-tail`) with a
  dead V1 fallback so `--no-default-features` still compiles.
- Cargo.toml: `default = ["guid-v3-tail"]` — every normal build has the V3
  mint path.
- ocr.rs + aiwar.rs: route through `mint_for(classid_read_mode(c).tail_variant,
  …)` instead of hardcoded `NodeGuid::new`. ocr is classid-param-driven (V3-
  ready). aiwar stays on the V1 `CLASSID_OSINT` (see below), behavior-preserving.
- .claude/commands/v3-audit.md: check #6 forbids `NodeGuid::new(` in non-test
  production code (mechanical guard).

Discovered blocker (documented, deferred): flipping aiwar to `CLASSID_OSINT_V3`
broke `projects_to_family_node_graph` — the V3 tail puts `family` at bytes
12..14 (u16) but `soa_graph::project_snapshot` reads it via the V1 `family()`
u24 accessor. So aiwar's V3-classid flip is now gated on making that consumer
tail-aware (I-LEGACY-API-FEATURE-GATED), not on the feature gate the issue
originally named. ISSUES.md carries the progress + remaining work.

Verification: 854 contract lib tests green (default); `--no-default-features`
compiles; `lance-graph` + `lance-graph-planner` check clean (default-on
propagates safely); fmt + clippy clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MLBnPuScZy6w9di2QEjsXM
@cursor

cursor Bot commented Jul 7, 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_ce8a3e4a-1ac6-4c8c-8921-6c21a7586a7a)

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR un-gates NodeGuid::mint_for into an unconditional implementation with TailVariant-based dispatch and a fallback path, enables guid-v3-tail by default, routes the ocr.rs and aiwar.rs production mint sites through mint_for based on registry-driven tail variants, adds a v3-audit grep check forbidding NodeGuid::new( in production code, and logs progress/blockers in the issues board.

Changes

V1-Tail-Residue Migration

Layer / File(s) Summary
Unconditional mint_for and default feature
crates/lance-graph-contract/src/canonical_node.rs, crates/lance-graph-contract/Cargo.toml
mint_for moved to an unconditional impl dispatching on TailVariant (V1 always via new, V2/V3 via new_v2 when guid-v2-tail is enabled, else fallback to new); guid-v3-tail enabled by default.
ocr.rs mint routing
crates/lance-graph-contract/src/ocr.rs
LayoutBlock::to_node_row now mints keys via mint_for using classid_read_mode(classid).tail_variant instead of a hardcoded NodeGuid::new.
aiwar.rs mint routing
crates/lance-graph-contract/src/aiwar.rs
aiwar_node_rows imports classid_read_mode, defines osint_classid, and mints the OSINT node key via mint_for based on the registered tail variant.
Audit check and progress log
.claude/commands/v3-audit.md, .claude/board/ISSUES.md
Adds a "V1-mint forbid" audit check for non-test NodeGuid::new( usage with sanctioned exceptions, and logs a 2026-07-07 issue entry documenting progress and a remaining aiwar/project_snapshot blocker.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Poem

A rabbit hops through tail and gate,
mint_for now runs unconditionally, straight!
V3 defaults, ocr and aiwar align,
no stray new( left in the production line.
🐇✨ hop, hop, migrate!

🚥 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 is concise and accurately captures the main changes: un-gating mint_for, enabling guid-v3-tail by default, and routing ocr/aiwar mints through it.
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.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/lance-graph-contract/src/aiwar.rs (1)

112-125: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clarify the V3 note in crates/lance-graph-contract/src/aiwar.rs:112-125: mint_for does not narrow family/identity automatically; the V2/V3 arm asserts both fit in 16 bits and panics otherwise, so the & 0x00FF_FFFF masks must be tightened if this path ever flips.

🤖 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/aiwar.rs` around lines 112 - 125, The
`NodeGuid::mint_for` call in `aiwar.rs` is annotated as if V3 would
automatically narrow `family` and `identity`, but the `V2/V3` path actually
asserts 16-bit fit and will panic if those values exceed it. Update the comment
and the masking logic around the `mint_for` invocation so it reflects the real
behavior, and tighten the `fam`/`identity` masks to 16 bits if this path can
ever switch to V3.
🧹 Nitpick comments (2)
crates/lance-graph-contract/src/ocr.rs (1)

104-132: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Redundant classid_read_mode(classid) lookup.

classid_read_mode(classid) is invoked twice — once at Line 105 for .value_schema and again at Line 124 for .tail_variant — for the same classid within the same call. Since ReadMode appears to carry both fields, cache the result once and reuse it.

♻️ Proposed refactor
     pub fn to_node_row(&self, classid: u32, identity: u32) -> NodeRow {
-        let schema = classid_read_mode(classid).value_schema;
+        let mode = classid_read_mode(classid);
+        let schema = mode.value_schema;
         let mut value = [0u8; VALUE_SLAB_LEN];
@@
             key: NodeGuid::mint_for(
-                classid_read_mode(classid).tail_variant,
+                mode.tail_variant,
                 classid,
🤖 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/ocr.rs` around lines 104 - 132, The
to_node_row method is doing the same classid_read_mode(classid) lookup twice for
one call. Cache the returned ReadMode once at the start of to_node_row, then
reuse its value_schema and tail_variant fields when building the NodeRow. This
keeps the logic in to_node_row unchanged while removing the redundant lookup.
crates/lance-graph-contract/src/aiwar.rs (1)

75-131: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Hoist classid_read_mode(osint_classid) out of the per-row closure.

osint_classid is loop-invariant (fixed at Line 81), but classid_read_mode(osint_classid).tail_variant (Line 117) is re-resolved inside .map() on every row. Hoist it once before the .map() call to avoid a redundant lookup per graph node.

♻️ Proposed refactor
     let view = AiwarClassView::from_graph(graph);
     let ids = graph.all_node_ids();
+    let tail_variant = classid_read_mode(osint_classid).tail_variant;
     let fam_of =
         |id: &str| -> Option<u32> { graph.node(id).and_then(|n| view.family_of(&n.label)) };
     ids.iter()
         .enumerate()
         .map(|(i, id)| {
@@
                 key: NodeGuid::mint_for(
-                    classid_read_mode(osint_classid).tail_variant,
+                    tail_variant,
                     osint_classid,
🤖 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/aiwar.rs` around lines 75 - 131, The per-row
closure in the `ids.iter().enumerate().map(...)` pipeline is re-resolving
`classid_read_mode(osint_classid).tail_variant` for every `NodeRow`, even though
`osint_classid` is ثابت and invariant. Hoist the
`classid_read_mode(osint_classid)` result (or at least its `tail_variant`) once
before the `.map()` call in `aiwar.rs`, then reuse that value inside
`NodeGuid::mint_for` so the lookup happens only once per batch instead of once
per node.
🤖 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.

Outside diff comments:
In `@crates/lance-graph-contract/src/aiwar.rs`:
- Around line 112-125: The `NodeGuid::mint_for` call in `aiwar.rs` is annotated
as if V3 would automatically narrow `family` and `identity`, but the `V2/V3`
path actually asserts 16-bit fit and will panic if those values exceed it.
Update the comment and the masking logic around the `mint_for` invocation so it
reflects the real behavior, and tighten the `fam`/`identity` masks to 16 bits if
this path can ever switch to V3.

---

Nitpick comments:
In `@crates/lance-graph-contract/src/aiwar.rs`:
- Around line 75-131: The per-row closure in the
`ids.iter().enumerate().map(...)` pipeline is re-resolving
`classid_read_mode(osint_classid).tail_variant` for every `NodeRow`, even though
`osint_classid` is ثابت and invariant. Hoist the
`classid_read_mode(osint_classid)` result (or at least its `tail_variant`) once
before the `.map()` call in `aiwar.rs`, then reuse that value inside
`NodeGuid::mint_for` so the lookup happens only once per batch instead of once
per node.

In `@crates/lance-graph-contract/src/ocr.rs`:
- Around line 104-132: The to_node_row method is doing the same
classid_read_mode(classid) lookup twice for one call. Cache the returned
ReadMode once at the start of to_node_row, then reuse its value_schema and
tail_variant fields when building the NodeRow. This keeps the logic in
to_node_row unchanged while removing the redundant lookup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5b4fb986-befb-4ad7-ba34-da9ccfeae001

📥 Commits

Reviewing files that changed from the base of the PR and between bcf3a63 and 44c67d1.

📒 Files selected for processing (6)
  • .claude/board/ISSUES.md
  • .claude/commands/v3-audit.md
  • crates/lance-graph-contract/Cargo.toml
  • crates/lance-graph-contract/src/aiwar.rs
  • crates/lance-graph-contract/src/canonical_node.rs
  • crates/lance-graph-contract/src/ocr.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