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.
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-wisdomdeterministic 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:
- Algorithmic semantics (control flow, data invariants, asymptotic complexity), and
- 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):
| Coordinate Axis | Threshold Intervals in [0.0, 1.0] | Piecewise-Discrete Deterministic Transform |
|---|---|---|
voice | Tiered comment-density thresholds (0.00 -> 1.00) | Inline rationale comments & block explanation frequency |
doc_level | [0, 0.33) None · [0.33, 0.66) Minimal · [0.66, 0.90) Standard · [0.90, 1.0] Academic | API docstrings, complexity tags, pre/post contract blocks |
naming | [0, 0.25) 1-char (i, n) · [0.25, 0.55) Short · [0.55, 0.85) Full · [0.85, 1.0] Math | Scope-aware alpha-renaming of bound local variables |
header | Thresholded [0.00 -> 1.00] banner fields (0 to 6 fields) | Module summary, invariants, complexity, and license header |
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):
| Optimization Stage | Search Space / Workload | Wall-Clock Latency (Apple Silicon) | Observed Loss Outcome |
|---|---|---|---|
Metal GPU Grid Search (R = 20) | 20^4 = 160,000 [0, 1]^4 grid points | 9.56 ms | Exhaustive coarse search across step-threshold boundaries |
| CPU Analytic Surrogate Polish | 5-seed local continuous surrogate descent | 4.01 ms | Sub-grid coordinate interpolation (Delta R < 0.05) |
Combined Fit (Hacker -> Knuth suite) | Style-feature distance before vs. after transform | 13.57 ms total | 60.9% style-feature distance reduction |
User preferences persisted locally in a bincode-serialized 3-tier Exponential Moving Average (EMA) hierarchy (Pattern-specific > Domain-specific > Global).
November 25, 2026 Errata, Related Work, and Evolution Addendum
Mathematical & Methodological Clarification Errata (2026-11-25 Audit)
- Reconciling
"Continuous 4D Space"+"Gradient Refinement"Against Piecewise-Discrete Code Transforms:- Piecewise-Constant Output Syntax: Although the parameter space
s in [0, 1]^4(andEMA/blend(A, B, t)arithmetic overs) is continuous, emitted source syntax is discrete: identifier choices (ivs.idxvs.element_index), docstring inclusion tiers (None / Minimal / Standard / Academic), and header field counts (0..6) change only whenscrosses piecewise-discrete bucket thresholds. Consequently, the actual code-emission maps |-> 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 subsequent4.01 msCPU stage differentiated a smooth analytic surrogate response curvef_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 in4dimensions, evaluating160,000scalar surrogate points (~a few millionFLOPs) 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.
- Piecewise-Constant Output Syntax: Although the parameter space
- Scope of the
60.9%Style-Distance Reduction &unmeteredProvenance:- 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 likerustfmt/Prettierhandle) 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.pdfunder CC BY-ND 4.0; the originalopenIE-dev/agi-wisdomcrate is a private repository (unreproduced externally).
- The
Chronological Evolution Within OpenIE Research
- 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.
- Deterministic Surface Normalization (Deterministic Code Spellcheck): Applied the same rule—avoid invoking stochastic models for deterministic surface transforms—to mechanical identifier and typo repair.
- 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.
Related Work & External References
- Oppen, D. C. (1980). Prettyprinting. ACM Transactions on Programming Languages and Systems (TOPLAS), 2(4), 465–483; Wadler, P. (1998 / 2003). A Prettier Printer — foundational deterministic line-breaking and layout algorithms underlying
clang-format,rustfmt, andPrettier. - Knuth, D. E. (1984). Literate Programming. The Computer Journal, 27(2), 97–111 — origin of the literate exposition paradigm modeled on the upper end of the
voice/doc_levelaxes. - Caliskan-Islam, A., Harang, R., Liu, A., Narayanan, A., Voss, C., Yamaguchi, F., & Greenstadt, R. (2015). De-anonymizing Programmers via Code Stylometry. USENIX Security Symposium 2015, 255–270 — landmark empirical quantification of programmer-specific lexical, layout, and AST style features.
- Allamanis, M., Barr, E. T., Bird, C., & Sutton, C. (2014). Learning Natural Coding Conventions (
NATURALIZE). FSE 2014, 281–293 — statistical identifier-naming and formatting convention inference on existing repositories.
Changelog (2026-11-25)
- Qualified
title,headlineMetric, and technical text to distinguish the continuous[0, 1]^4coordinate vector from piecewise-discrete AST/token threshold tiers, and renamed/explained CPU"gradient refinement"as smooth analytic-surrogate coordinate polish. - Separated Part I (January 22, 2026 summary) from Part II (November 25, 2026 mathematical errata, 4-feature self-evaluation scope, and private-repo disclosure).
- Added prior-art citations to Oppen (TOPLAS 1980), Wadler (1998),
Prettier,rustfmt,clang-format, Knuth (1984), Caliskan-Islam et al. code stylometry (USENIX Security 2015), and Allamanis et al.NATURALIZE(FSE 2014).
David Charlot
Open Interface Engineering, Inc. · Signed Provenance · Self-Checked
Archival PDF (#10) public at /papers/archive/10-Style-Engine-4D-Code-Personality.pdf under CC BY-ND 4.0; original Style Engine repository (openIE-dev/agi-wisdom) is private (externally unreproduced). Full licensing & AI-use disclosure →
Video Summaries, Syndication & Site Reference
Check the primary artifacts or run an independent replication
Inspect signed provenance manifests, rerun our public Apache-2.0 commodity-hardware replication kits, review our November 25, 2026 outside-review errata, or browse primary manuscripts on the Research Hub.