4D Code Personality Coordinates Over Piecewise-Discrete AST Transforms: The Style Engine

January 22, 2026 whitepaper factoring surface code presentation out of LLMs into ~1,800 lines of deterministic Rust parameterized by [0, 1]^4 coordinates over piecewise-discrete AST tiers across 37 languages, with a 9.56 ms Metal grid search and analytic surrogate coordinate polish.

Illustration contrasting human-oriented code presentation with machine canonical structure
Illustration contrasting human-oriented code presentation with machine canonical structure

Temporal & Archival Scope: Era 0 Historical Whitepaper (Originally dated January 22, 2026; verbatim historical summary followed below by dated November 25, 2026 Errata & Related Work Addendum) · Canonical OpenIE Chronicle Entry: https://blog.openie.dev/posts/wp-style-engine-4d-code-personality/ · Original Archival PDF: https://blog.openie.dev/papers/archive/10-Style-Engine-4D-Code-Personality.pdf

Provenance & Telemetry Hygiene: Signed Provenance · Self-Checked (automated OpenIE internal gates; not externally peer-reviewed) · Energy Class: unmetered (measured_j ⊥ reported_j ⊥ est_j ⊥ unmetered — Verification, Licensing & AI-Use Disclosure · Glossary & Non-Mixing Rules).

Part I: Contemporary Historical Summary (As Written in January 2026)

Historical Source Provenance (Original Date: January 22, 2026): David Jean Charlot, PhD · Open Interface Engineering. Preserved from our January 2026 agi-wisdom deterministic synthesis series (Download Original Jan 2026 PDF).

Thesis: Factoring Surface Presentation Out of Neural Code Generation

Prompting a frontier LLM to “rewrite this module in terse Kernighan C” or “add literate Knuth documentation” entangles two distinct operations inside a single stochastic forward pass:

  1. Algorithmic semantics (control flow, data invariants, asymptotic complexity), and
  2. Surface presentation (identifier verbosity, comment cadence, docstring detail, file provenance banners).

Re-sampling an entire function through an autoregressive model solely to adjust naming or comment density risks mutating boundary logic non-deterministically. The January 2026 Style Engine (~1,800 lines of Rust) separated presentation into a deterministic post-pass parameterized by a 4D coordinate vector s in [0, 1]^4 across 37 target languages (originally titled “Continuous 4D Code Personality” — see Nov 25, 2026 Errata below on continuous coordinates vs. piecewise-discrete output syntax).

The [0, 1]^4 Coordinate Vector & Thresholded Transform Tiers

Each profile s = (voice, doc_level, naming, header) in [0, 1]^4 drove five ordered token/AST post-processing passes parameterized by per-language CommentSyntax tables across 37 targets (including Rust, C, Python, Go, TypeScript, Swift, Haskell, OCaml, Ada, Fortran, and COBOL):

Storing profiles as real vectors in [0, 1]^4 allowed convex coordinate blending blend(A, B, t) = (1 - t)*A + t*B between named presets:

Named Preset Coordinates in [0, 1]^4  (voice, doc_level, naming, header):
  Torvalds   = (0.25, 0.00, 0.33, 0.33)   // terse kernel C, zero docstring ceremony
  Kernighan  = (0.25, 0.33, 0.00, 0.33)   // compact loop indices, minimal banners
  Dijkstra   = (0.50, 0.66, 1.00, 0.66)   // mathematical identifiers + explicit invariants
  Knuth      = (0.75, 1.00, 0.66, 1.00)   // literate exposition & full 6-field header

Apple Metal Grid Search & Analytic Surrogate Polish

To infer a repository’s house coordinate s* in [0, 1]^4 from existing source files without training neural adapters, the engine combined static style-feature extraction with an Apple Metal GPU grid search and CPU local polish (originally termed “CPU analytical gradient refinement” — see Nov 25, 2026 Errata below):

User preferences persisted locally in a bincode-serialized 3-tier Exponential Moving Average (EMA) hierarchy (Pattern-specific > Domain-specific > Global).


Mathematical & Methodological Clarification Errata (2026-11-25 Audit)

  1. Reconciling "Continuous 4D Space" + "Gradient Refinement" Against Piecewise-Discrete Code Transforms:
    • Piecewise-Constant Output Syntax: Although the parameter space s in [0, 1]^4 (and EMA / blend(A, B, t) arithmetic over s) is continuous, emitted source syntax is discrete: identifier choices (i vs. idx vs. element_index), docstring inclusion tiers (None / Minimal / Standard / Academic), and header field counts (0..6) change only when s crosses piecewise-discrete bucket thresholds. Consequently, the actual code-emission map s |-> AST_text(s) is a non-smooth step function with zero gradient almost everywhere and discontinuities at tier boundaries!
    • What CPU “Gradient Refinement” Actually Differentiated: That step-function discontinuity is why the 20^4 = 160,000-point Metal grid search was needed to locate the active discrete tier basin (9.56 ms), while the subsequent 4.01 ms CPU stage differentiated a smooth analytic surrogate response curve f_hat(s) (a continuous sigmoidal/linear approximation to comment-to-code ratio, mean identifier length, and docstring density over [0, 1]^4)—NOT true differentiation through discrete AST token emission! Notice also that in 4 dimensions, evaluating 160,000 scalar surrogate points (~a few million FLOPs) could run in a few milliseconds on multi-core CPU SIMD alone without requiring a GPU, making the Metal kernel an engineering convenience rather than a computational necessity.
  2. Scope of the 60.9% Style-Distance Reduction & unmetered Provenance:
    • The 60.9% loss drop measured Euclidean distance on the engine’s own 4-feature summary vector (comment ratio, docstring coverage, identifier length, header presence)—it did not touch layout/line-breaking width algorithms (which tools like rustfmt/Prettier handle) or human blind-review Turing tests of authentic Knuth/Dijkstra prose!
    • No hardware energy counters were collected (unmetered). Archival PDF (#10) is public at /papers/archive/10-Style-Engine-4D-Code-Personality.pdf under CC BY-ND 4.0; the original openIE-dev/agi-wisdom crate is a private repository (unreproduced externally).

Chronological Evolution Within OpenIE Research

  1. Testing How Surface Conventions Affect Machine Comprehension (How AI Reads Human Code): Moved from treating identifier/comment tiers purely as human cosmetics to measuring empirically how surface naming and comments alter LLM and compiler comprehension.
  2. Deterministic Surface Normalization (Deterministic Code Spellcheck): Applied the same rule—avoid invoking stochastic models for deterministic surface transforms—to mechanical identifier and typo repair.
  3. Canonical Graph IR vs. Surface Views (Reality Code Engine (RCE) & The AI Coding Market): Reinforced the architectural split between canonical machine-verified graph representations and human-facing textual views.

Changelog (2026-11-25)


Canonical Provenance, Primary Artifacts & Independent Replication