Skip to content

Commit 69c3b12

Browse files
committed
docs: incorporate grill answers into three-tier model
Three confirmed answers written back to the canonical doc: 1. MailboxId IS the NiblePath — u32 mailbox_id is itself the HHTL radix-trie key; entity_type: u16 removal from SoA rows is total, no separate prefix field survives. 2. Class<Template> codegen is build-time + JIT split — known OGAR classes via build.rs/proc-macro at compile time; runtime-discovered classes via JITson (lance-graph-planner / Cranelift) at first use. 3. Tool dispatch = compile-time Rust trait impls — monomorphized per class via HHTL prefix ancestry; zero-cost, no vtable, no dyn. https://claude.ai/code/session_0147hSzjmWZDuy2MSQNrhEK5
1 parent c78a55f commit 69c3b12

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

docs/architecture/soa-three-tier-model.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ ontology schema. This is Tier 3 because it is *inherited*, not stored per-row.
9090
**Resolution chain:**
9191

9292
```
93-
mailbox address (MailboxId + family prefix)
93+
mailbox address = u32 mailbox_id = NiblePath (MailboxId IS the NiblePath)
9494
95-
▼ HHTL / NiblePath prefix lookup
95+
▼ HHTL radix-trie prefix walk — the u32 itself is the trie key
9696
│ NiblePath::is_ancestor_of:
9797
│ (other.path >> (4*(other.depth-self.depth))) == self.path
9898
│ = prefix ancestry = class ancestry (Confirmed)
@@ -107,11 +107,15 @@ OGIT radix-trie codebook (O(1) for known classes at compile time)
107107
For new/runtime classes: JIT via lance-graph-planner (JITson / Cranelift)
108108
```
109109

110-
**`entity_type: u16` in SoA may be redundant.** If the ontology resolves O(1)
111-
from address, hardcoding a handle in every row violates SoC and defeats
112-
radix-trie cheapness. The current linear scan in `OntologyRegistry::
113-
enumerate_first_with_entity_type_id` is a defect — it should be an O(1)
114-
`Vec` index keyed by the 1-based ordinal.
110+
**MailboxId IS the NiblePath.** The `u32 mailbox_id` field in `MailboxSoA` is not
111+
a handle into a separate lookup — it IS the NiblePath key that the HHTL radix trie
112+
walks. No separate prefix field survives. This makes `entity_type: u16` in every
113+
SoA row entirely redundant: if the ontology resolves O(1) from the address, the
114+
per-row handle violates SoC and defeats radix-trie cheapness. **`entity_type: u16`
115+
removal from SoA rows is total** once O(1) lookup is the sole path. The current
116+
linear scan in `OntologyRegistry::enumerate_first_with_entity_type_id` is a defect
117+
— it should be an O(1) `Vec` index keyed by the 1-based ordinal, or removed entirely
118+
once the per-row handle is gone.
115119

116120
**OGAR active record / DLL AST adapter:** OGAR classes get pragmatic mapping
117121
to inherited tools at compile time. These are cheap inherited registers, not
@@ -205,7 +209,12 @@ means. A class is:
205209
(`MappingRow`); never duplicated into SoA rows.
206210
- **Tools** — the methods / adapters that operate on the register. These are
207211
inherited from the class hierarchy (HHTL prefix ancestry = class ancestry).
208-
A subclass inherits all parent tools without restating them.
212+
A subclass inherits all parent tools without restating them. The dispatch
213+
mechanism is **compile-time Rust trait impls**: one `impl Tool for ClassFoo`
214+
per class, monomorphized at build time from the HHTL inheritance chain.
215+
Zero-cost — no vtable, no `dyn`, no runtime dispatch. "Cheap inherited
216+
registers" in the architecture doc is literal: the trait impl IS the register,
217+
and the compiler erases it to a direct call.
209218
- **Codegen templates** — Askama/Jinja `Class<Template>` views (see below).
210219
- **Active record** — the class instance wraps a slice of the register bank
211220
and provides the domain API. Methods come from the class hierarchy; data
@@ -227,14 +236,23 @@ means. A class is:
227236
no new fields; register IS the data
228237
```
229238

230-
### Askama/Jinja codegen = masked selection from the class DTO
239+
### Askama/Jinja codegen = masked selection from the class DTO — split by known vs JIT
231240

232241
A `Class<Template>` is not a new type. It is a **masked selection** over the
233242
class DTO: the template declares which fields it reads, the codegen emits only
234243
those fields as strongly-typed Rust from the class schema, and the result is a
235244
zero-overhead view — one `select` mask over one class, compiled to a concrete
236245
struct by the Askama/Jinja template engine.
237246

247+
**When does this codegen happen? Both — split by known vs JIT:**
248+
249+
- **Known OGAR classes** (those in the codebook at compile time): `build.rs` /
250+
proc-macro emits concrete Rust structs at build time. Zero runtime cost;
251+
the compiler sees the full type.
252+
- **Runtime-discovered / new classes**: `JITson` path in `lance-graph-planner`
253+
(Cranelift backend). The template is instantiated at first encounter and
254+
compiled to native code. Same masked-selection semantics, deferred to first use.
255+
238256
```
239257
OGAR Class { field_a, field_b, field_c, tool_x, tool_y, template_T }
240258

0 commit comments

Comments
 (0)