/** Principle: keep geometry, roles, and constructors separate Right now you have three conceptual layers: - Vocabulary / ontology What is a block, pixel, role, level, channel? → Tiling.ts - Pure geometry / index sets What does a 4×4 grid mean at the type level? → grid definitions, cartesian products - Role-specific constructors How do we construct “payload pixels”, “link pixels”, “echo pixels”? → payload/link/echo constructors This mirrors exactly how you think about the system: - tiling is the substrate - grids are pure geometry - pixel constructors are semantic overlays This file answers one question only: “Given a payload block and a coordinate, what is the payload pixel?” That’s perfect spec granularity. */ import type { BlockAssignment, TypedTiledPixel, PixelAssignment, } from "./tiling.ts"; import type { Grid4x4 } from "./grid.ts"; /** * Construct a single payload pixel inside a Level-2 block. * * This is a PURE TYPE-LEVEL constructor: * - no runtime values * - no side effects * * It represents one "fat pixel" contribution to a HASSE value cell. */ export type PayloadPixel< B extends BlockAssignment<2>, P extends readonly [number, number] > = PixelAssignment<2> & { owner: B["owner"]; level: 2; block: B["block"]; role: B["role"]; pixel: TypedTiledPixel<2> & { block: B["block"]; index: { ix: P[0]; iy: P[1] }; role: "Payload"; channel: "Data"; }; }; /* ----------------------------------------------------- */ /* 2. Union → tuple helpers */ /* ----------------------------------------------------- */ type UnionToIntersection = (U extends unknown ? (x: U) => void : never) extends (x: infer I) => void ? I : never; type UnionToTuple = [U] extends [never] ? T : UnionToIntersection void : never> extends (u: infer I) => void ? UnionToTuple, [...T, I]> : T; /* ----------------------------------------------------- */ /* 3. All payload pixels for a payload block */ /* ----------------------------------------------------- */ /** * All payload pixels for a Level-2 payload block. * * This is the 4×4 “fat pixel” surface of a HASSE value cell. */ export type PayloadPixelsForBlock< B extends BlockAssignment<2> > = UnionToTuple< Grid4x4 extends infer P ? P extends readonly [number, number] ? PayloadPixel : never : never >;