Skip to content

Commit 7441cd3

Browse files
committed
lance-graph-contract: codegen_manifest::MethodSig — the C++ codegen compile target
The MethodSig EXTEND-CORE (C-FIRST step 2's deferred-runtime-registry piece). A new codegen_manifest module: - MethodSig: the dispatch-relevant C++ method signature in a const-constructible shape (all fields &'static: name, params: &'static [&'static str], ret, is_const, is_static, overrides). It is the exact literal ruff_cpp_codegen::render emits, so the generated text now has a real compile target. The &'static shape is load-bearing: class_view::FieldRef is String-backed and cannot appear in a const; MethodSig is the method-axis sibling that can. - ClassMethods{classid, methods} + methods_for(registry, classid): the registry-entry type + pure zero-fallback lookup (unregistered classid -> empty slice). classid is bound OGAR-side, never minted here; the runtime classid->methods registry DATA is generated downstream (consumer repo), NOT stored here (honest-tester's "defer the runtime registry"). Additive (container-architect ADDITIVE-CONFIRMED): a sibling module, zero NodeRow/ValueTenant/ValueSchema/stride/ENVELOPE_LAYOUT_VERSION impact. Body-shaping flags (pure-virtual/constexpr/noexcept/operator/requires) are out of scope. Board hygiene: LATEST_STATE Contract Inventory updated same commit (D-CPP-CODEGEN-1). +2 tests (const-constructibility proof + zero-fallback); 640 contract lib green; clippy -D warnings clean. C-FIRST: D + emitter scaffold + MethodSig EXTEND-CORE all landed; the in-env arc is complete. Remaining is operator-gated (tesseract-rs wiring + byte-parity). Co-Authored-By: Claude <noreply@anthropic.com> https://claude.ai/code/session_016b33swuXE23hKtqxsHu9p1
1 parent b504159 commit 7441cd3

4 files changed

Lines changed: 179 additions & 0 deletions

File tree

.claude/board/LATEST_STATE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282

8383
## Current Contract Inventory (lance-graph-contract)
8484

85+
> **2026-06-17 — ADDED (D-CPP-CODEGEN-1, C-FIRST step 2 compile target)**: `lance_graph_contract::codegen_manifest::{MethodSig, ClassMethods, methods_for}` — the Core-side target of the C++ method-resolution manifest emitted by `ruff_cpp_codegen` (the Tesseract AST-DLL pipeline's stage 2). `MethodSig` is the dispatch-relevant signature in a **`const`-constructible** shape (all fields `&'static`: `name`, `params: &'static [&'static str]`, `ret`, `is_const`, `is_static`, `overrides`) — the method-axis sibling of `class_view::ClassView`'s field projection, deliberately NOT `String`-backed (a generated `const X: &[MethodSig] = &[MethodSig { .. }]` must compile; `FieldRef` is `String`-backed and cannot). `ClassMethods{classid, methods}` is the registry ENTRY the generated code emits (classid bound OGAR-side, never minted here); `methods_for(registry, classid) -> &'static [MethodSig]` is the pure lookup with zero-fallback (unregistered classid → empty slice). **Additive** (container-architect ADDITIVE-CONFIRMED): a sibling module, zero `NodeRow`/`ValueTenant`/`ValueSchema`/stride/`ENVELOPE_LAYOUT_VERSION` impact; the runtime `classid→methods` registry DATA lives downstream (generated in the consumer repo), not here. Body-shaping flags (pure-virtual/constexpr/noexcept/operator/requires) are out of scope (they drive body generation, not the signature manifest). The 8-agent step-2 council's deferred-runtime-registry resolution. +2 tests (const-constructibility proof + zero-fallback lookup); 640 contract lib green; clippy `-D warnings` clean. Plan: `.claude/plans/transcode-extend-core-probe-v1.md` (C step 2). Consumer: `ruff_cpp_codegen::render` (AdaWorldAPI/ruff) names this type in emit-text-only output.
86+
8587
> **2026-06-16 — ADDED (4-task unblock-cascade)**: `lance_graph_contract::hhtl::NiblePath::{from_guid_prefix(&NodeGuid) -> Option<NiblePath>, prefix(depth: u8) -> Option<NiblePath>}` — the ontology-side keystone follow-up of #498's `classid → ReadMode` LE contract. The 20-nibble `classid · HEEL · HIP · TWIG` prefix is deterministically folded to 16 (the canon-reserved high `u16` of classid drops); returns `None` when the fold would be lossy (callers don't get silent collisions). `prefix(d)` is the O(1) single-shot ancestor view that satisfies `prefix(d).is_ancestor_of(self)` for every `d ≤ self.depth` — the routing-cache view of a deeper class path. **One layer up** in `cognitive-shader-driver::MailboxSoA<N>`: `impl MailboxSoaView + MailboxSoaOwner` (cherry-pick of `jolly-cori-clnf9::463d71b`) + the `pub phase: KanbanColumn` field — the in-RAM Rubicon owner the contract's `MailboxSoaOwner` had no real implementor for (integrated-cognitive-planner-v1 §2 Seam #3 closed). In `lance_graph::graph::scheduler`: `LanceVersionScheduler<S = NextPhaseScheduler>` — D-MBX-9-IN core impl over `VersionedGraph::versions()`, generic over the inner `VersionScheduler` policy (closes `E-SUBSTRATE-IS-THE-SCHEDULER`'s OUT-direction). In `surreal_container::view`: `SurrealMailboxView<'a>` + `read_via_kv_lance()` (D-PG-6 contract slice) — the SurrealQL read-glove the integrator wires once the cold-build of the surrealdb fork is taken; the contract surface is available today. Plus `SurrealContainerError::BlockedColdBuild` — typed signal for callers to pattern-match the cold-build gate (distinct from the pre-existing `Blocked` variant which signals coordinate/API gaps). Zero-dep contract additions (+7 hhtl tests, 632 lib green); cognitive-shader-driver +1 driving-loop test (86 lib green); lance-graph::scheduler new module (+5 tests, real tempdir Lance); surreal_container::view new module (+4 tests). All four green; clippy `-D warnings` clean on the new files. EPIPHANIES `E-UNBLOCK-CASCADE-1` records the convergence of three independent landings onto the single `MailboxSoaView` trait surface.
8688

8789
> **2026-06-09 — ADDED (D-IDENTITY-1, Phase A of identity-architecture)**: `lance_graph_contract::identity::{NodeGuid([u8;16]), IDENTITY_LAYOUT_VERSION}` — the workspace's first **stable binary instance identity**: a structured 128-bit UUIDv8 (RFC 9562) = the HHTL nibble-address **formalized + namespaced**. **Composed from existing committed scalars, never re-invented** (Agent A sweep confirmed the 128-bit id space was empty): octets carry `namespace:u8 | entity_type:u16 | kind:u8` (the `SchemaPtr.packed` convention) ⊕ a truncated `NiblePath` routing prefix (`PREFIX_NIBBLES=4`) ⊕ a 22-bit `shape_hash` (truncated `StructuralSignature`) ⊕ a 24-bit `local`, with UUIDv8 version(=8)/variant(=0b10) at their RFC-fixed positions + an `IDENTITY_LAYOUT_VERSION` stamp. **Eineindeutigkeit**: `entity_type` is the canonical exact class identity; the `NiblePath` prefix is the bijective DERIVED view (a *truncated* prefix can't be the identity — deep classes collide past it; the prefix `is_ancestor_of` the full path). Five readings: resolve (`entity_type`) / route (`niblepath`) / witness (frozen bytes + merkle) / ground-truth (`shape_hash` drift) / dispatch-to-store (`as_bytes` → `EntityKey`). Also added `hhtl::NiblePath::from_packed` (inverse of `packed`). Zero-dep; 599 contract lib tests (+15: field-isolation matrix, UUIDv8 gates, ancestor-prefix invariant, Display=canonical-UUID); clippy `-D warnings` clean; fmt clean. Plans: `identity-architecture-exists-vs-needs-v1.md` (exists-vs-needs map + phases A→H), `cognitive-write-roundtrip-substrate-v1.md`. Epiphany: E-IDENTITY-WHITEBOX-1.

.claude/plans/transcode-extend-core-probe-v1.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,35 @@ names. It touches operator-locked canon (additively), so unlike D and the
403403
scaffold (ruff-internal correctness/codegen) it is the deliberate-Core-growth
404404
step the doctrine says to file + review before landing. Then: wire the generated
405405
crate in tesseract-rs and run byte-parity (Option B, operator's leptonica host).
406+
407+
### MethodSig EXTEND-CORE — LANDED (2026-06-17, AdaWorldAPI/lance-graph)
408+
409+
`lance_graph_contract::codegen_manifest` shipped (the council pre-review =
410+
file + review; container-architect ADDITIVE-CONFIRMED):
411+
412+
- **`MethodSig`** — the dispatch signature in a `const`-constructible shape (all
413+
fields `&'static`: `name`, `params: &'static [&'static str]`, `ret`,
414+
`is_const`, `is_static`, `overrides`). This is the exact literal
415+
`ruff_cpp_codegen::render` emits, so the generated text now has a real compile
416+
target. The `&'static` shape is the whole point — `class_view::FieldRef` is
417+
`String`-backed and cannot appear in a `const`; `MethodSig` is the method-axis
418+
sibling that can.
419+
- **`ClassMethods{classid, methods}`** + **`methods_for(registry, classid)`**
420+
the registry-entry type + pure zero-fallback lookup. classid is bound
421+
OGAR-side (never minted here); the runtime `classid→methods` registry DATA is
422+
generated downstream (consumer repo), NOT stored in lance-graph — the
423+
honest-tester's "defer the runtime registry" honored.
424+
- **Additive**: a sibling module, zero `NodeRow`/`ValueTenant`/`ValueSchema`/
425+
stride/`ENVELOPE_LAYOUT_VERSION` impact. Board hygiene: LATEST_STATE Contract
426+
Inventory updated in the same commit (D-CPP-CODEGEN-1). +2 tests
427+
(const-constructibility proof — the load-bearing property — + zero-fallback
428+
lookup); 640 contract lib green; clippy `-D warnings` clean.
429+
430+
**C-FIRST status:** D ✓ → emitter scaffold ✓ → MethodSig EXTEND-CORE ✓. The
431+
in-env, lance-graph-internal arc of the pipeline is complete: a C++ harvest now
432+
flows harvest → reassemble → project → render → a `MethodSig` manifest whose
433+
type exists in the Core. **Remaining (operator-gated, out of this env):** wire
434+
the generated crate into tesseract-rs (needs the leptonica build env) and run
435+
`PROBE-OGAR-ADAPTER-UNICHARSET` byte-parity (Option B) — the only path to
436+
CONJECTURE→FINDING. Everything to here is CONJECTURE per the doctrine; the
437+
`PARITY: UNRUN` markers on every generated file say so.
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
//! Codegen manifest types — the Core-side target of the C++ method-resolution
2+
//! manifest emitted by `ruff_cpp_codegen` (the AST-DLL pipeline's stage 2).
3+
//!
4+
//! `ruff_cpp_spo` harvests a C++ corpus into SPO triples; `ruff_spo_triplet`
5+
//! reassembles the method plane; `ruff_cpp_codegen` renders it as Rust source
6+
//! that names [`MethodSig`]. This module is the **compile target** of that
7+
//! generated text.
8+
//!
9+
//! # Why `&'static`, not `String`
10+
//!
11+
//! Every field is `&'static` so a generated
12+
//! `const X: &[MethodSig] = &[MethodSig { .. }]` compiles. The render-side
13+
//! manifest could not target [`crate::class_view::ClassView`]'s `fields()`
14+
//! because `FieldRef` is `String`-backed (not `const`-constructible);
15+
//! `MethodSig` is the method-axis sibling, deliberately all-`&'static`.
16+
//!
17+
//! # What lives here vs. downstream
18+
//!
19+
//! This module provides the **type + lookup**. The **data** — the per-class
20+
//! `const … : &[MethodSig]` tables and the `&[ClassMethods]` registry — is
21+
//! generated downstream (in the consumer repo, e.g. tesseract-rs) and is NOT
22+
//! held here; lance-graph mints no C++ classids and stores no method tables.
23+
//! The classid is bound OGAR-side (the `ocr.rs::to_node_row(classid, …)`
24+
//! precedent — classid is a parameter, never minted by the manifest). A runtime
25+
//! `classid → methods` registry is intentionally deferred: this is the minimal
26+
//! additive Core growth (`MethodSig` is the dispatch signature; the body
27+
//! adapters and a populated registry come later).
28+
//!
29+
//! `MethodSig` carries only the dispatch-relevant signature (name, ordered
30+
//! params, return, `is_const`/`is_static`, override target). The body-shaping
31+
//! flags the harvest also captures (`is_pure_virtual` / `constexpr` /
32+
//! `noexcept` / operator-kind / `requires`) drive body generation, not the
33+
//! signature manifest, and are not represented here.
34+
35+
/// One C++ method's dispatch-relevant signature, in a `const`-constructible
36+
/// shape (all fields `&'static`). This is the exact literal
37+
/// `ruff_cpp_codegen::render` emits.
38+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
39+
pub struct MethodSig {
40+
/// Bare method name (e.g. `unichar_to_id`, `operator==`).
41+
pub name: &'static str,
42+
/// Parameter types in signature order, verbatim
43+
/// (e.g. `&["const char *", "int"]`).
44+
pub params: &'static [&'static str],
45+
/// Return type, verbatim. `None` for void / constructors / destructors.
46+
pub ret: Option<&'static str>,
47+
/// `T method() const;` — a const-qualified (read-accessor) member.
48+
pub is_const: bool,
49+
/// `static T method();` — a class-level member (no implicit `this`).
50+
pub is_static: bool,
51+
/// The fully-qualified overridden base method (cv-aware), if any.
52+
pub overrides: Option<&'static str>,
53+
}
54+
55+
impl MethodSig {
56+
/// Number of parameters.
57+
#[must_use]
58+
pub const fn arity(&self) -> usize {
59+
self.params.len()
60+
}
61+
62+
/// Whether this method overrides a virtual base method.
63+
#[must_use]
64+
pub const fn is_override(&self) -> bool {
65+
self.overrides.is_some()
66+
}
67+
}
68+
69+
/// One class's method manifest, keyed by classid — the registry ENTRY the
70+
/// generated code emits. The classid is bound OGAR-side; this type only
71+
/// associates an already-minted classid with its `const` method table.
72+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
73+
pub struct ClassMethods {
74+
/// The OGAR classid this manifest belongs to.
75+
pub classid: u32,
76+
/// The class's methods (a generated `const` table).
77+
pub methods: &'static [MethodSig],
78+
}
79+
80+
/// Resolve a classid to its method manifest within a generated `registry`
81+
/// slice. The Core provides the lookup; the `registry` data is generated
82+
/// downstream. Returns an empty slice for an unregistered classid (the
83+
/// zero-fallback ladder: an unknown class resolves to "no methods", never a
84+
/// panic).
85+
#[must_use]
86+
pub fn methods_for(registry: &[ClassMethods], classid: u32) -> &'static [MethodSig] {
87+
registry
88+
.iter()
89+
.find(|entry| entry.classid == classid)
90+
.map_or(&[], |entry| entry.methods)
91+
}
92+
93+
#[cfg(test)]
94+
mod tests {
95+
use super::*;
96+
97+
/// The load-bearing property: `MethodSig` is `const`-constructible. This is
98+
/// the exact shape `ruff_cpp_codegen::render` emits — if it ever stopped
99+
/// compiling in a `const`, the generated manifests would too. (Contrast
100+
/// `FieldRef`, which is `String`-backed and cannot appear in a `const`.)
101+
const SAMPLE: &[MethodSig] = &[
102+
MethodSig {
103+
name: "unichar_to_id",
104+
params: &["const char *"],
105+
ret: Some("UNICHAR_ID"),
106+
is_const: true,
107+
is_static: false,
108+
overrides: None,
109+
},
110+
MethodSig {
111+
name: "kSpaceId",
112+
params: &[],
113+
ret: Some("UNICHAR_ID"),
114+
is_const: false,
115+
is_static: true,
116+
overrides: None,
117+
},
118+
];
119+
120+
const REGISTRY: &[ClassMethods] = &[ClassMethods {
121+
classid: 0x0001,
122+
methods: SAMPLE,
123+
}];
124+
125+
#[test]
126+
fn const_manifest_constructs_and_reads() {
127+
assert_eq!(SAMPLE.len(), 2);
128+
assert_eq!(SAMPLE[0].name, "unichar_to_id");
129+
assert_eq!(SAMPLE[0].arity(), 1);
130+
assert!(SAMPLE[0].is_const);
131+
assert!(!SAMPLE[0].is_override());
132+
assert!(SAMPLE[1].is_static);
133+
assert_eq!(SAMPLE[1].arity(), 0);
134+
}
135+
136+
#[test]
137+
fn methods_for_resolves_classid_with_zero_fallback() {
138+
assert_eq!(methods_for(REGISTRY, 0x0001).len(), 2);
139+
assert!(
140+
methods_for(REGISTRY, 0xDEAD).is_empty(),
141+
"an unregistered classid resolves to no methods (zero-fallback)"
142+
);
143+
}
144+
}

crates/lance-graph-contract/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub mod callcenter;
4444
pub mod cam;
4545
pub mod canonical_node;
4646
pub mod class_view;
47+
pub mod codegen_manifest;
4748
pub mod codegen_spine;
4849
pub mod cognitive_shader;
4950
pub mod collapse_gate;

0 commit comments

Comments
 (0)