一键导入
leeway-beginner
Use to learn Leeway fundamentals — the backbone (plain values) vs payload (tagged values) architecture and basic columnar data modelling.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use to learn Leeway fundamentals — the backbone (plain values) vs payload (tagged values) architecture and basic columnar data modelling.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use this skill when writing ClickHouse SQL transformation passes, pipelines, macro expanders, function evaluators, or analysis functions using the nanopass framework. Triggers include: any mention of 'nanopass', 'SQL pass', 'SQL transformation', 'SQL rewrite', 'ClickHouse pass', 'canonicalize SQL', 'macro expansion', 'qualify tables', 'expand columns', 'extract literals', 'add/modify SETTINGS', or requests to manipulate ClickHouse SQL programmatically in Go. Also use when parsing ClickHouse SQL, walking a CST, rewriting tokens, building scope-aware transformations, declaring PassProperties, or composing SQL→SQL pipelines with Sequence/FixedPoint. Do NOT use for general SQL querying, ClickHouse client usage, or ORM-based database access.
Use when writing imzero2 / egui2 GUI code — the FFFI render pipeline, memory management, the deterministic XOR id stack, retained/deferred bodies, and widget contracts.
Use for advanced Leeway columnar modelling — multi-membership encoding, co-sections, membership roles, and mapping JSON to an equivalent Leeway representation.
Use when generating, parsing, or manipulating Canonical Type Signatures (CT) — the compact string representation of data types (primitives, groups, signatures) for RPC/FFI interface descriptions.
Use when defining or consuming a Go↔native (Rust/C++) FFI boundary with FFFI2 (frame-oriented foreign function interface) — writing the IDL, generating stubs, or using the runtime API.
Use when calling imzero2 Fetcher.Fetch* opcodes — they must run only from StateManager.Sync() at frame end; calling them inline from a widget or deferred-block body deadlocks the render loop.
| name | leeway-beginner |
| description | Use to learn Leeway fundamentals — the backbone (plain values) vs payload (tagged values) architecture and basic columnar data modelling. |
| type | reference |
| audience | agent reading this skill |
| status | draft |
Status: draft — pre-human-review. Not verified; do not cite as authoritative.
Leeway is a schema-on-write data representation protocol designed to bridge the gap between semi-structured data (JSON/Document) and high-performance columnar storage (DuckDB, Arrow, ClickHouse).
It decouples Topology (hierarchy/nesting) from Content (values). Instead of storing domain-specific objects, Leeway shreds data into type-specific Sections, managing structure via Memberships and Cardinality Vectors. This enables "Zero-Copy" schema evolution, vectorized processing of sparse data, and seamless transition between row-oriented transport (Streaming) and column-oriented storage (OLAP).
Leeway partitions data into two orthogonal planes: the Backbone (Plain Values) and the Payload (Tagged Values).
Attributes that define the existence, identity, and lifecycle of an entity. They map 1:1 to the logical row and are mandatory for structural integrity.
| Item Type | Description | Physical Type |
|---|---|---|
| Entity | Primary Identity (e.g., blake3hash). | y (Blob) |
| Timestamp | Primary event time. | i64 (Epoch ns) |
| Routing | Partition keys, topics, offsets. | s (String) |
| Lifecycle | Row state (Active, Tombstone). | u8 (Enum) |
| Transaction | MVCC/Consistency IDs. | u64 |
| Opaque | Data Mart / BI Projections. Conventional, non-shredded columns (e.g., total_revenue) added to the table to support standard SQL tools that cannot query shredded sections. | Varies |
Data is shredded by Canonical Type, not by domain field.
float64, string, bool).user.age, metrics.cpu).> [Figure 1: The Shredding Prism – Illustrating how a JSON document splits into type-specific silos]
Types are defined by a machine-readable tuple notation (AST Nodes), strictly separating storage format from semantic meaning.
(Base, Width, Endian, Structure)
u,i,f: Unsigned, Signed, Float.8..64: Bit width.l,n: Little/Network Endian.h,m: Homogenous Array / Set.i,64,l,- (int64), f,32,n,h (Float32 Vector).(Type, Format, Size, Structure)
s: UTF8 String.y: Byte Blob.f: Fixed width (e.g., for UUIDs).Leeway replaces nested tree structures with flat, vectorized lookups using a Graph model.
Defines how values associate with logical tags.
hostname). Stored via Dictionary Encoding.tags[0], map["uuid-1"]). The key is split into a static "Tag" (tags/_) and a dynamic "Parameter" stored in a parallel column.> [Figure 2: The Zipper – Illustrating how High Cardinality keys are split into Schema (Low Card) and Data (High Card/Param)]
Support columns that handle non-scalar data and aliasing.
value-card: Defines the number of scalars per logical value.
value-card=9.membership-card: Defines the number of tags per logical value.
19.99 can be tagged as both /price and /min_price. membership-card=2.Leeway enforces a Self-Describing Naming Convention. The physical column name encodes the full schema, including configuration and optimization hints, allowing reconstruction without a registry.
ColumnRoleE)A Section is composed of multiple physical columns working in unison (Co-Arrays).
| Role | Enum | Description |
|---|---|---|
| Value | val | The actual data payload. |
| Low-Card Verbatim | lmv | The dictionary-encoded tag/path. |
| High-Card Param | mvhp | The dynamic parameter (index/key). |
| Membership Card | lmvcard | Support: Maps M memberships to 1 value. |
| Value Card | valcard | Support: Maps N scalars to 1 logical value. |
Format: [Prefix]:[Section]:[LogCol]:[Role]:[Type]:[Hints]:[Semantics]:[Config]:[Group]:
To keep names concise and URL-safe, Aspects (Encoding Hints, Value Semantics, Use Aspects) are serialized as bitmasks and encoded using Base62.
Example: "tv:bool:lmvcard:lmvcard:u64:4gw:0:0:0::"
4gw reveals specific compression settings (e.g., Delta Encoding + ZSTD).> [Figure 3: Co-Array Alignment – Illustrating how Tag indices align physically with Value indices]
Definition: Two sections are "Co-Sections" if they share the exact same Topology (Cardinality).
CoSectionGroup. If Attribute A exists in Section X, it must exist in Co-Section Y.Blob data in Section A and lightweight int64 metadata in Co-Section B. The membership overhead is paid only once.> [Figure 4: Multi-Membership & Co-Sections – Illustrating aliasing and shared topology]
Definition: A subset of sections that must be transported together in row-oriented protocols (Kafka/Pulsar).
Leeway tables can be sliced vertically at Section/Co-Section boundaries. A valid Leeway subset must contain:
The SDK follows a Definition $\to$ Synthesis $\to$ Runtime pattern.
common)TableManipulator: Fluent API to construct schemas programmatically.mapping: Utilities to infer Leeway schemas from JSON samples.TableDesc: The immutable schema definition.dml.GoClassBuilder: Generates Ingestion structs (InEntity).
readaccess.GoClassBuilder: Generates Query structs (ReadAccess).
MembershipPacks and Accelerators (O(1) lookups).ddl.GeneratorDriver: Generates storage definitions for Arrow, ClickHouse (SQL), and Go.InEntity structs to buffer data and TransferRecords to flush to Arrow batches.ReadAccess structs to load Arrow batches and perform vectorized queries.| Feature | Leeway | JSON / Document | Parquet / Arrow | Relational (SQL) |
|---|---|---|---|---|
| Structure | Graph (Shredded) | Tree (Nested) | Tree (Nested Levels) | Flat (Rigid) |
| Schema | Physical (On-Write) | Implicit (In-Data) | Header / Registry | DDL (Pre-defined) |
| Map Keys | Parameters (Data) | Keys (Parsing req.) | Explosion (Schema break) | Not Supported / JSONB |
| Polymorphism | Native (Type Routing) | Native | Union Types (Complex) | Impossible |
| Storage | Sparse Vectors | Dense Blobs | Dense / Sparse | Dense |
| Aliasing | Multi-Membership | Duplication | Duplication | Duplication |
Input:
{"hostname": "server-a", "tags": ["prod"], "metrics": {"cpu": 45.5}, "active": true}
Logical Shredding:
/hostname $\to$ string Section (Tag: /hostname)/tags/0 $\to$ symbol Section (Tag: /tags/_, Param: 0)/metrics/cpu $\to$ float64 Section (Tag: /metrics/cpu)/active $\to$ bool Section (Tag: /active)Physical Table (ClickHouse Arrays):
| Section | Column Name (Base62 decoded for readability) | Value | Notes |
|---|---|---|---|
| Backbone | id:blake3... | ["hash-1"] | Entity ID |
| String | tv:string:val... | ["server-a"] | Value |
tv:string:lmv... | ["/hostname"] | Tag | |
| Symbol | tv:symbol:val... | ["prod"] | Value |
tv:symbol:lmv... | ["/tags/_"] | Tag (Schema) | |
tv:symbol:mvhp... | ["0"] | Param (Data) | |
| Float64 | tv:float64:val... | [45.5] | Value |
tv:float64:lmv... | ["/metrics/cpu"] | Tag |
Q1. In a standard Leeway schema, where does the integer value 42 for the attribute user.profile.age end up residing?
A) In the user table, under the profile_age column.
B) In the int64 section, grouped with all other integers from the document.
C) In a JSONB blob column named properties.
D) In the age section, which is a dedicated column for user ages.
Q2. How does Leeway prevent "Map Key Explosion" when handling dynamic keys like UUIDs?
A) It creates a new column for every unique UUID.
B) It stores the entire object as an Opaque JSON blob.
C) It treats the keys as "High Cardinality Parameters," storing them in a data column (mvhp) while keeping the schema tag static.
D) It hashes the UUIDs and drops the original strings.
Q3. You have a large 1024-dimension float vector. You want to tag it as both "ImageEmbedding" and "SearchContext" without duplicating the heavy data. How does Leeway handle this?
A) Using Multi-Membership: The value is stored once, and the membership-card column maps it to two tags.
B) Using Co-Sections: You create two sections that share the value.
C) You must insert the value twice.
D) Using Virtual Columns.
Q4. A section is defined with the canonical type (f, 64, -, h) (Homogenous Array). If a single logical row contains a 3x3 matrix (9 floats), what does the value-card column contain?
A) 3 (Rows)
B) 1 (One Object)
C) 9 (Scalar Units)
D) 0
Q5. Where does a tool look to find the schema definition (Types, Hints, Semantics) for a physical column?
A) It queries the system.leeway_registry table.
B) It parses the column name itself, decoding the Base62 segments.
C) It looks for a companion .proto file.
D) It cannot determine the schema; this is an internal column.
Q6. What is the primary purpose of an "Opaque" column? A) To store binary blobs that cannot be shredded. B) To provide a conventional, read-oriented view (Data Mart) for BI tools. C) To encrypt sensitive data. D) To store the original JSON for debugging only.
Q7. Section A is defined as a "Co-Section" of Section B. What does this imply? A) They contain the exact same values. B) They share the same Topology (Cardinality). C) They must be stored on the same disk. D) Section A is a backup of Section B.