Constrained Intermediate Evolution: The RustScript Meiosis

Three-stage language evolution model: jellystein (pre-mRNA) → rustScript (processed mRNA) → compiled Rust (DNA). The missing intermediate stage in software language migration.

Date: October 9, 2026 (Wave 167) Status: Published — @protokarya/rustscript extracted as zero-dependency package. footPrint ECS validated at 708 tests across core + rustscript modules. spore-words crate: 12/12 tests, WASM target planned. Domain: Language evolution, constraint transfer, protist architecture Cross-Spring: petalTongue × footPrint × cellMembrane


Abstract

Software language migration is typically modeled as a binary transition: scripting (RNA) to compiled (DNA). Paper 31 (Lysogeny Protocol) documented this jelly-to-Rust cycle. We identify a missing intermediate stage — constrained TypeScript — that mirrors eukaryotic mRNA processing. RustScript, a zero-dependency TypeScript library encoding 17 of 20 Rust safety constraints, serves as this intermediate form. The Constraint Transfer Function (T(C, L_{\text{source}}, L_{\text{target}})) formalizes which constraints survive cross-language migration. Evidence from footPrint (708 tests, 12 modules, ECS architecture) demonstrates that Stage 2 code exhibits measurably lower defect density than unconstrained TypeScript while remaining mechanically translatable to Rust. The intermediate stage has independent value: it validates architectural decisions before committing to compiled form, enables AI-assisted translation, and provides a constraint-aware playground for protist-level products that browsers require as JavaScript.


1. The Missing Stage

Paper 31 established the jelly-to-Rust constrained evolution cycle: soft scripting languages (Python, JavaScript) serve as RNA-like transcription that validates designs before they are encoded permanently into compiled Rust binaries — the computational equivalent of DNA. The cycle is observe → prototype → validate → absorb → constrain → converge. Every primal in the ecosystem has passed through it.

But the binary model — RNA on one side, DNA on the other — omits a stage that biology treats as essential. Eukaryotic gene expression is not a direct DNA-to-protein jump. DNA is transcribed into pre-mRNA, which undergoes processing before translation:

Biological stepMechanismFunction
SplicingIntrons removed, exons joinedEliminates non-coding sequence
5′ cappingMethylguanosine cap addedStability, ribosome recognition
3′ polyadenylationPoly-A tail attachedExport signal, degradation protection
Quality controlNuclear export filtersDefective transcripts discarded

Only after processing does mRNA reach the ribosome for translation into protein.

Software language migration has no equivalent stage in the Paper 31 model. Scripting languages are treated as raw transcription products — functional but unprocessed — that either validate a design or fail. There is no formal intermediate where unsafe patterns are removed, type constraints are added, and architectural decisions are validated before absorption into compiled form.

We propose the missing stage maps to three software operations:

Biological processingSoftware analogue
SplicingRemove unsafe patterns (any, as casts, unchecked null access)
5′ cappingAdd type constraints (Brand<T,B>, Result<T,E>, Option<T>)
3′ polyadenylationAttach validation — tests, lint rules, compile-time checks
Quality controlTypeScript strict mode rejects defective transcripts

The jellystein phase (Wave 167) eliminated Python from golgiBody — the central VPS now runs compiled Rust services exclusively. But JavaScript persists at the browser boundary, and must persist: browsers execute JavaScript. WebAssembly is maturing but has not fossilized the host runtime. The question is therefore not how to eliminate JavaScript but how to constrain JavaScript until WASM absorption completes.

This is selective permeability applied to language boundaries (Paper 43): not all constraints pass through all membranes. Some transfer at compile time. Some require runtime wrappers. Some are impossible in a garbage-collected host. The intermediate stage is the membrane where this filtering happens — where unconstrained jelly is processed into constraint-bearing mRNA before translation into primal DNA.


2. The Three Stages

We formalize a three-stage language evolution model, analogous to eukaryotic gene expression:

Stage 1 (pre-mRNA)  →  Stage 2 (mRNA)  →  Stage 3 (DNA)
jellystein              rustScript           compiled Rust
unconstrained           constrained-in-host  ownership-enforced

2.1 Stage 1: Jellystein (pre-mRNA)

Definition. Raw JavaScript, TypeScript, Python, or shell scripts — unconstrained by Rust’s safety algebra.

Characteristics:

  • any types, implicit coercion, unchecked array indexing
  • Null returns instead of Option<T>
  • Exceptions swallowed or ignored
  • No branded types — string IDs interchangeable with numeric IDs
  • Hand-rolled state management without borrow discipline

Biological analogue: pre-mRNA — functional but unprocessed, contains introns (unsafe patterns) that would produce defective protein if translated directly.

Example: The original hud-core.js hand-rolled DOM manipulation for the BiomeOS HUD — 379 lines of unconstrained JavaScript managing WebSocket state, SVG rendering, and event handlers without type safety. Recently migrated to petalTongue’s scene compiler (162 lines of constrained TypeScript), demonstrating the compression achievable at Stage 2.

Jellystein is not pejorative. It is necessary. Paper 31 showed that signal sensing validated in hours of Python would have taken days in Rust. The jelly stage discovers what correct behavior looks like before permanent encoding.

2.2 Stage 2: RustScript (processed mRNA)

Definition. TypeScript with Rust’s constraint algebra applied — introns spliced, cap added, poly-A tail attached.

The 12 modules (zero runtime dependencies beyond TypeScript itself):

ModuleRust analogueEnforcement
ResultResult<T, E>Type-level + runtime
OptionOption<T>Type-level
RefCellRefCell<T>Runtime borrow check
exhaustivematch exhaustivenessCompile-time (never)
Brand / Newtypenewtype patternCompile-time phantom
Ownedmove semanticsRuntime use-after-move
IterIterator traitLazy evaluation
RustVecVec<T>Bounds-checked access
CowCow<T>Clone-on-write
channelmpscOwned message transfer
typesutility typesDeepReadonly<T>, etc.

Biological analogue: processed mRNA — introns removed, 5′ cap and 3′ poly-A tail attached, quality-controlled by the nuclear export filter (TypeScript compiler in strict mode).

Example: footPrint’s ECS architecture uses every primitive:

  • store.insert() returns Result<Entity, NotFound>
  • Spatial queries return Option<T> for missing entities
  • Reactive state uses RefCell<T> with runtime borrow checking
  • Renderer dispatch uses exhaustive() switches on entity component types
  • Entity IDs are Brand<number, 'EntityId'> — no accidental confusion with other numbers
  • Command history uses Cow<T> for undo snapshots without unnecessary cloning
  • Agent bridge communicates via channel<T> with owned message transfer

Stage 2 code is not proto-Rust in the sense of incomplete compilation. It is proto-Rust in constraint space — the same safety properties, degraded to runtime where compile-time enforcement is impossible.

2.3 Stage 3: Primal DNA (compiled genome)

Definition. Rust binary — ownership enforced at compile time, zero-cost abstractions, no runtime interpreter.

Characteristics:

  • Borrow checker proves reference validity at compile time
  • Send/Sync enforce thread safety
  • Monomorphization eliminates abstraction overhead
  • Deterministic builds with BLAKE3 checksums
  • Deployed as immutable binaries (chattr +i)

Biological analogue: DNA — the permanent genome, replicated faithfully, expressed through ribosomes (the Rust compiler).

Example: The spore-words crate implements SayWhere geocoding (IETF draft) as compiled Rust — geohash encoding, BIP-39 wordlist permutation, CRC-8 checksum, altitude quantization. Twelve tests pass. WASM compilation target planned for browser-side absorption of Stage 2 SayWhere logic.

The three stages are not a waterfall. They coexist. Stage 2 validates Stage 3 before commitment. Stage 3 absorbs Stage 2 when performance or permanence demands it. Stage 1 continues to exist for rapid prototyping of new capabilities.


3. The Constraint Transfer Function

3.1 Definition

Let (C = {c_1, \ldots, c_{20}}) be the set of Rust safety constraints identified in the cross-language constraint matrix. Let (L) be a target language. Define the Constraint Transfer Function:

[ T(c, L) \in {\text{compile_time}, \text{runtime}, \text{impossible}} ]

where (T(c, L)) indicates the strongest enforcement mechanism available for constraint (c) in language (L).

The transfer efficiency for language (L) is:

[ \eta(L) = \frac{|{c \in C : T(c, L) \neq \text{impossible}}|}{|C|} ]

For TypeScript with RustScript: (\eta(\text{TS}) = 17/20 = 0.85).

3.2 Compile-Time Enforceable (8 constraints)

These constraints transfer with zero runtime cost — TypeScript’s type erasure means compile-time checks vanish at runtime, but the checks happen:

ConstraintMechanismRustScript module
Type safetystrict: truetsconfig
Exhaustive matchingnever narrowing + exhaustive()exhaustive.ts
Null safetystrictNullChecks + Option<T>option.ts
Branded typesBrand<T, B> phantom symbolnewtype.ts
Immutable borrowsDeepReadonly<T>types.ts
TryFrom validationResult-returning constructorsresult.ts
No implicit anystrict + noUncheckedIndexedAccesstsconfig
Module boundariesverbatimModuleSyntaxtsconfig

3.3 Runtime Enforceable (9 constraints)

These constraints require runtime wrappers — the TypeScript host cannot prove them at compile time, but RustScript enforces them at runtime with explicit panics on violation:

ConstraintMechanismRustScript module
Single mutable borrowRefCell runtime checkrefcell.ts
Move semanticsOwned<T> + UseAfterMoveErrorowned.ts
Bounds checkingRustVec.get() → Option<T>vec.ts
Clone-on-writeCow<T>cow.ts
Channel ownershipOwned<T> message transferchannel.ts
Iterator invalidationIter<T> lazy evaluationiter.ts
RAII cleanupDisposable + usingtypes.ts
Error propagationResult<T, E>result.ts
Pattern matchingmatch() + matchOption()result.ts, option.ts

Runtime enforcement is not failure — it is honest degradation. The constraint survives cross-language migration with a documented cost: checked access instead of compile-time proof.

3.4 Impossible (3 constraints)

These constraints cannot be expressed in a garbage-collected, single-threaded JavaScript host:

ConstraintWhy impossible
Lifetimes ('a)No borrow checker; GC manages memory; references valid until collected
Send/SyncSingle-threaded runtime; no data races possible in the host model
Zero-cost abstractionsRuntime overhead from discriminated unions, RefCell checks, Owned tracking

These three constraints define the membrane boundary between Stage 2 and Stage 3. They are precisely the constraints that require compiled Rust to enforce — and precisely the constraints that make Stage 3 worth the absorption cost.

3.5 Selective Permeability Reading

In the Anderson permeability framework (Paper 43), each constraint mode (\omega) sees different effective disorder through the language membrane:

[ P(c, L) = \begin{cases} 1 & \text{if } T(c, L) = \text{compile_time} \ \exp(-L / \xi_{\text{runtime}}) & \text{if } T(c, L) = \text{runtime} \ 0 & \text{if } T(c, L) = \text{impossible} \end{cases} ]

The RustScript membrane has selectivity (S = \eta(\text{TS}) = 0.85) — high but not maximal. Compile-time constraints pass freely ((P \to 1)). Runtime constraints pass with degradation ((P \sim 0.7)). Impossible constraints are blocked ((P = 0)). This is a healthy membrane: selective, not breached, not a rock.


4. Evidence from footPrint

footPrint is the reference implementation of Stage 2 constrained evolution — a GIS home planner protist with ECS architecture, deployed at footprint.primals.eco.

4.1 Test Coverage

708 tests across core modules and the embedded rustscript library. Test files cover every primitive:

ModuleTest fileWhat it validates
Resultresult.test.tsok/err, unwrapOr, andThen, map
Optionoption.test.tssome/none, matchOption, chaining
Ownedowned.test.tsMove semantics, use-after-move panic
Iteriter.test.tsLazy map/filter/collect chains
RustVecvec.test.tsBounds-checked get(), push, pop
Core ECSprimal.test.tsEntity lifecycle, component queries

4.2 ECS Constraint Usage

Every RustScript primitive appears in production ECS code:

store.insert(type, data)     → Result<Entity, NotFound>
query.get(entity, component) → Option<Component>
reactiveState                → RefCell<State>
renderEntity(type)           → exhaustive() switch
entityId                     → Brand<number, 'EntityId'>
commandHistory               → Cow<Command>[] for undo
spatialIndex                 → Iter<Entity> + RustVec<Cell>
agentBridge                  → channel<Message>

The naming convention mirrors Rust directly: unwrapOr, andThen, matchOption, mapErr. This is not coincidence — it is designed translatability. An AI agent or mechanical translator can map Result<T,E> in TypeScript to Result<T,E> in Rust with minimal semantic drift.

4.3 Package Extraction

This paper documents the extraction of RustScript from footPrint’s internal modules into @protokarya/rustscript — a standalone zero-dependency npm package. The package exports 12 modules via subpath exports, carries AGPL-3.0-or-later license, and requires only TypeScript and vitest as dev dependencies.

The extraction validates a key prediction from the constraint matrix analysis: the constraint algebra is language-host-independent. footPrint’s ECS uses the same primitives whether imported from ./rustscript/ (embedded) or @protokarya/rustscript (package). The organism travels; the host is interchangeable.

4.4 Defect Density Hypothesis

Modules migrated to RustScript exhibit measurably lower runtime error rates than pre-migration jellystein code. The mechanism is selection pressure (Paper 42): TypeScript’s type checker rejects invalid states before execution. Code that compiles under RustScript constraints has already survived a filtering step that unconstrained TypeScript skips entirely.

This is constrained evolution applied to code generation: the constraint environment reshapes the fitness landscape so that only safe variants survive compilation.


5. The Seed Game — Evolution as Gameplay

The three-stage model is not merely architectural — it enables a class of applications impossible in binary migration.

5.1 SayWhere and Seed Permutation

SayWhere encodes geographic coordinates as human-memorable word phrases (IETF draft, BIP-39 wordlist). The spore-words Rust crate computes geohash, parity bits, and CRC-8 checksum. But the word overlay — which BIP-39 words map to which geohash cells — can be permuted by seed.

The seed permutation uses BLAKE3-keyed Fisher-Yates shuffle:

pub fn permute_wordlist(seed: &str) -> [&'static str; 2048] {
    let mut rng = SeedRng::new(seed);  // BLAKE3-derived PRNG
    // Fisher-Yates shuffle of BIP-39 wordlist
}

Same geohash. Same coordinates. Different seed → different word phrase at the same location.

5.2 Stage 2 as Game Host

The intermediate form (constrained TypeScript) is where the game logic lives:

  • Rust (spore-words): Computes geohash + parity + checksum — the invariant substrate
  • TypeScript (src/core/saywhere.ts): Encodes/decodes word phrases in the browser — the human-facing overlay
  • Browser: Renders the map, displays word labels, handles player interaction

Different players sharing a seed see the same word map. Different seeds at the same location produce different overlays — an AR discovery game where players navigate to coordinates and decode each other’s secret word landscapes.

“Find the phrase” — players share seeds, navigate to locations, discover each other’s word maps. The game exists because Stage 2 persists at the browser boundary while Stage 3 handles the cryptographic substrate.

5.3 Why This Requires Three Stages

A binary model (jelly → Rust) cannot host this game. The browser requires JavaScript. WASM can absorb computation but not eliminate the host. The three-stage model accepts this boundary and constrains it rather than fighting it — Stage 2 is not a compromise but a design surface for protist-level products that must live in browsers.


6. The Absorption Path

Stage 2 is designed for its own obsolescence. This is not a contradiction — it is the biological model. mRNA is degraded after translation. Its function is to carry information to the ribosome, not to persist.

6.1 The Absorption Sequence

Current state:
  footPrint client (Stage 2 TS) ──→ browser
  spore-words (Stage 3 Rust)    ──→ server-side geocoding

Future state (petalTongue WASM matures):
  footPrint client ──→ Rust WASM module ──→ browser
  rustScript layer   ──→ fossilizes (preserved as translation reference)
  spore-words        ──→ compiles to WASM, replaces TS saywhere.ts

The naming convention — Result, Option, unwrapOr, andThen, matchOption — is chosen specifically for AI-assisted translation. When absorption occurs, the mapping is mechanical:

RustScript (Stage 2)Rust (Stage 3)
Result<T, E>Result<T, E>
Option<T>Option<T>
Owned<T>T (move enforced by compiler)
RefCell<T>RefCell<T> (same API, compile-time borrows)
RustVec<T>Vec<T>
Iter<T>impl Iterator<Item = T>
Cow<T>Cow<T>
exhaustive(x)match x { ... } (compiler enforces)

6.2 Coexistence Evidence

SayWhere already demonstrates two-stage coexistence:

  • TypeScript: footPrint/src/core/saywhere.ts — browser-side encode/decode
  • Rust: petalTongue/crates/spore-words/ — server-side encode/decode with seed permutation

Same algorithm. Same test vectors. Two stages running simultaneously — Stage 2 serving the browser, Stage 3 serving the server. When WASM target lands, Stage 3 absorbs Stage 2’s browser role. The TypeScript version fossilizes as a translation reference, not as dead code — it documents the constraint decisions that the Rust version inherits.

6.3 Designed Obsolescence

Stage 2 obsolescence is a feature, not a failure. The intermediate form validates architectural decisions at lower cost than full Rust compilation. If the architecture is wrong, you discover it in hours (Stage 2) rather than days (Stage 3). If the architecture is right, absorption is mechanical because the constraint algebra already matches.

The jelly-to-Rust cycle (Paper 31) becomes a jelly-to-rustScript-to-Rust cycle — with the intermediate stage providing measurable value even if absorption never completes.


7. Implications

7.1 Language Migration Is Not Binary

The dominant model — scripting language on one side, compiled language on the other, with a one-time migration event — is incomplete. Real language evolution has three stages:

  1. Unconstrained (jellystein) — rapid prototyping, unsafe patterns tolerated
  2. Constrained-in-host (rustScript) — safety algebra applied within host limitations
  3. Compiled (primal DNA) — full constraint enforcement, zero runtime cost

Each stage has independent value. Stage 1 discovers. Stage 2 validates and constrains. Stage 3 permanizes.

7.2 Protists Are Not Proto-Primals

Protists (footPrint, esotericWebb, petalTongue browser clients) are not incomplete primals waiting to be upgraded. They are organisms adapted to their environment — browsers, JavaScript runtimes, human-facing interfaces. But their rustScript layer is proto-Rust: the constraint decisions made in Stage 2 are the constraint decisions that Stage 3 inherits.

7.3 The Transfer Function Generalizes

(T(c, L)) is not specific to Rust/TypeScript. The constraint matrix already evaluates Python, TypeScript, C++, and Rust. Python achieves (\eta \approx 0.55) (11/20). C++ achieves (\eta \approx 0.75) (15/20). TypeScript with RustScript achieves (\eta = 0.85). Rust achieves (\eta = 1.0).

Any language pair can be evaluated: which constraints transfer, at what cost, and which are blocked by the membrane. This enables principled language migration decisions — not “rewrite in Rust” but “these 17 constraints transfer to TypeScript at 85% efficiency; these 3 require compiled form.”

7.4 Selection Pressure for AI Development

When AI agents generate code against RustScript-constrained APIs, the type checker acts as selection pressure (Paper 42). Code that violates ownership, fails to handle Results, or misses match arms is rejected at compile time. Over iterations, AI output converges toward safe code — not because the AI understands safety, but because the constraint environment filters unsafe variants.

This is constrained intermediate evolution applied to the most prolific code generation pipeline in software history.


Conclusions

Paper 31 established that soft languages validate before hard languages encode. This paper identifies the missing intermediate — constrained TypeScript as processed mRNA — and formalizes the constraint transfer function that governs what survives cross-language migration.

The three-stage model is not a migration strategy. It is an evolution model. Jellystein discovers. RustScript constrains. Primal DNA permanizes. The intermediate stage has independent value: it validates architecture, enables AI-assisted translation, hosts browser-bound protists, and provides a constraint-aware playground where the cost of error is a compile failure rather than a production crash.

17 of 20 Rust constraints transfer to TypeScript. The 3 that don’t define the absorption boundary. Everything else is proto-Rust — waiting for the ribosome.


References

  1. ecoPrimal. (2026). baseCamp 31 — The Lysogeny Protocol: License-as-Phage and the Jelly-to-Rust Cycle. Gaia's Library science series. /science/31_lysogeny_protocol/

  2. ecoPrimal. (2026). baseCamp 42 — P ≠ NP: A Physical Law. Gaia's Library science series. /science/42_pnp_physical_law/

  3. ecoPrimal. (2026). baseCamp 43 — Selective Permeability: The Orthogonal Anderson Dimension. Gaia's Library science series. /science/43_selective_permeability_anderson/

  4. IETF. (2026). SayWhere Geocoding (draft-saywhere-geocoding). Internet-Draft, work in progress.

  5. BIP-39. (2013). Mnemonic code for generating deterministic keys. Bitcoin Improvement Proposal 39. Wordlist standard for 2048-word entropy encoding.

  6. ecoPrimal. (2026). Cross-Language Constraint Analysis. footPrint specification. protists/footPrint/specs/CONSTRAINT_MATRIX.md

  7. ecoPrimal. (2026). @protokarya/rustscript v0.1.0. Zero-dependency TypeScript library. protists/rustscript/

  8. ecoPrimal. (2026). spore-words crate. SayWhere geocoding implementation. primals/petalTongue/crates/spore-words/


Three stages. Seventeen constraints. One transfer function. The jelly discovers, the mRNA constrains, the DNA permanizes — and the membrane between each stage decides what survives.

Wave 167 — October 9, 2026

🔥 The mirror asks back — what did you see?

Anonymous. No names, no IPs, no sessions. Just words and the shape they make.