Design Philosophy

The Story of the Step Runner

How we moved away from rigid monolithic UI generation toward an agnostic, step-driven, 3-dimensional pipeline.

1. The Problem with Monolithic UI Builders

In traditional web libraries, generating complex UI components (such as multi-column data tables, select option matrices, or interactive form sections) is usually tightly coupled to DOM creation APIs or huge monolithic functions. If you wanted to adjust the order of colgroups, headers, or body rows, you had to rewrite loop logic, manage mutable DOM element handles, and deal with browser side-effects.

"A UI renderer should not be responsible for calculating geometry or maintaining internal transformation algorithms. It should only be an orchestrator that executes declarative blueprints step by step."

When building high-throughput JSON renderers, having the runtime know what a "table" is creates architectural friction. What if tomorrow you want to render a dropdown, a datalist, or a mobile card list using the exact same step-by-step logic?

2. The 4 Generations of Evolution

The architecture of json-renderers-run-instructions-steps was refined across 4 clear evolutionary milestones:

Version 1 — The Monolithic Step Runner

The initial step-by-step experiment. It proved that sequentially applying instruction names was vastly superior to giant functions, but it contained defensive checking bloat, coupled blueprints, and rigid error catches.

Version 2 — The 4-Line executeStep Breakthrough

Stripped away all defensive check overhead. executeStep was reduced to a pure 4-line function: resolve instruction, dispatch dimension type, mutate destination path, and return result.

Version 3 — 2D Matrix Orchestration

Replaced custom matrix loops with json-transformer-funcs-two-dimensions (rowOnColumn and columnOnRow), establishing the tri-dimensional mathematical framework (0D, 1D, 2D).

Version 4 — Decoupled Blueprints

Achieved separation of concerns. Instruction definitions were extracted to declarative-instructions, while templates moved to declarative-spec.

Version 5 (v13) — Pure Orchestration Across Single & Multi (Current)

Split mixed blueprints into declarative-instructions-single and declarative-instructions-multi, removed the legacy monolithic catalog, and reduced executeStep.js to pure orchestration routing { type, key } descriptors into dedicated single/index.js and multi/index.js workers.

3. The 3D Spatial Mathematical Model

Every declarative UI element naturally lives in one of three mathematical spaces:

Dimension Nature Engine Function Example Output
0D (Primitive) Singular Object Mapping applyTemplate Cards, Badges, Form Wrapper
1D (Linear) 1-Dimensional Array Projection fromCollection Colgroups (<col>), Headers (<th>)
2D (Matrix) Cartesian Cross-Product (Row × Col) rowOnColumn / columnOnRow Table Body (<tr><td>), Select Options

Because of this clear mathematical separation, the step runner doesn't have a single nested loop. It simply reads the instruction's type and invokes the corresponding specialized transformer function.

4. Zero-DOM & Zero Garbage Collection Overhead

Traditional declarative frameworks often clone the entire component tree on each step to ensure immutability. When constructing a table of 500 rows and 20 columns, this leads to 10,000 intermediate nodes cloned multiple times, triggering heavy GC pauses.

json-renderers-run-instructions-steps achieves extreme performance by performing **deterministic in-place mutations** into pre-allocated branches of the canvas tree using json-write-path. The execution is synchronous, pure, and produces identical results every run without GC pressure.

Architectural Lesson

5. The Canvas Contract: Why We Mandate base and Never baseKey

During the evolution between version 5 and 6, an experiment was conducted to pass baseKey (a string pointing to a catalog key) instead of the actual base specification object. At first glance, it seemed like a convenience — letting the runner look up the template itself.

However, this proved to be an architectural blunder that broke the foundational tenets of the system:

"The step runner is a craftsperson operating on a canvas handed to it. It does not go to the warehouse to pick out the canvas; the orchestrator provides the canvas, the runner paints the structural elements, and hands that exact canvas back."

With Version 7, the architecture is locked in: runInstructions receives base, mutates base in place, and returns base. Never pass baseKey.