language: en kae3g ← back to index
(unlisted) — This essay is not shown on the main index but remains accessible via direct link

kae3g 9515: Regenesis Demo - Make It Tactile

Status: Scaffolded | Implementation: In Progress
Goal: One-button demo showing the complete stack breathing

What Is Regenesis?

Regenesis (not genesis!) = Eternal return, continuous rebirth

Why "Re"?:

Theologically: Not creation ex nihilo, but re-creation ex spec

Ecologically: Not planting seeds, but regenerating from living root systems (Helen Atthowe!)

Mathematically: Not inventing new math, but re-deriving from frozen axioms (Nock's 12 rules!)

The Regenesis Ritual

One command regenerates the entire valley:

bb regenesis

Or with the valley CLI (symlink):

./valley regenesis

What it does:

  1. Build: Compile Nostr relay (GraalVM native image OR JVM)
  2. Start: Boot fake Urbit ship (-F zod)
  3. Serve: Launch ClojureScript frontend (shadow-cljs)
  4. Connect: Wire Nostr → Urbit → UI
  5. Send: Verified message through complete stack
  6. Measure: Record metrics (startup, latency, equivalence)
  7. Report: Write var/reports/regenesis.json
  8. Announce: "The valley regenerates. Your first noun recomputes."

Dual-Runtime Verification

The demo exercises BOTH paths:

Fast Path (GraalVM - Phenotype)

bb regenesis:fast

# Measures:
# - Startup time (target: < 50ms)
# - Message latency (target: < 10ms)
# - Memory footprint (target: < 100MB)

This is the MUTABLE phenotype - optimized for today's world.

True Path (Nock - Genotype)

bb regenesis:true

# Measures:
# - Nock reduction steps
# - Equivalence to Clojure output
# - Verification coverage (%)

This is the IMMUTABLE genotype - eternal specification.

Verify Equivalence

bb regenesis:verify

# Checks:
# ✓ Fast output = True output (same noun!)
# ✓ All test vectors pass
# ✓ Reductions logged

The proof that they're the SAME computation - just different instantiations!

Proof Obligations

For each transformation, we maintain:

1. Equivalence Notes (.nock.md)

Template:

# Equivalence Note: Nostr Event Filter

**Intent**: Filter Nostr events by kind (e.g., text notes only)

**Clojure path**:
\`\`\`clojure
(ns nostr.core
  (:require [clojure.spec.alpha :as s]))

;; Spec for event
(s/def ::kind int?)
(s/def ::content string?)
(s/def ::event (s/keys :req-un [::kind ::content]))

;; Pure function
(defn filter-by-kind [events kind-target]
  (filter #(= (:kind %) kind-target) events))
\`\`\`

**Nock form** (canonical reduction):
\`\`\`
; Input noun: [events-list kind-target]
; Output noun: [filtered-events-list]

; Nock formula (conceptual):
?[events target]
  ; Apply test to each event
  ; Keep events where (= kind target)
  ; Deterministic transformation
\`\`\`

**Claim**: The Clojure function and Nock reduction are semantically equivalent for all valid inputs.

**Evidence**:
- Test vectors: `var/golden/filter-by-kind/inputs.json`
- Expected outputs: `var/golden/filter-by-kind/outputs.json`
- Reductions log: `var/golden/filter-by-kind/reductions.log`

**Status**: ✅ Verified (100 random test cases passed)

2. Jet Notes (.jet.md)

Template:

# Jet Note: Event Filter Optimization

**Purpose**: Fast path for `filter-by-kind` that preserves Nock semantics

**Nock expression** (from `filter-by-kind.nock.md`):
\`\`\`
?[events target] ; conceptual Nock reduction
\`\`\`

**Host jet** (optimized Clojure):
\`\`\`clojure
(defn filter-by-kind-jet [events kind-target]
  ;; Optimized with transducers
  (into [] (filter #(= (:kind %) kind-target)) events))
\`\`\`

**Mapping**:
- Nock recursive reduction → Clojure transducer (O(n) same complexity)
- Deterministic: Same inputs → same outputs
- Verified: Cross-checked against golden nouns

**Performance**:
- Nock interpreter: ~1000ms (1000 events)
- Jet optimization: ~5ms (1000 events)
- **Speedup: 200x** (while preserving semantics!)

**Tests**: CI asserts jet output = Nock output for all golden test vectors

**Status**: ✅ Verified equivalence, deployed in production

Metrics Tracked

Written to var/reports/regenesis.json:

{
  "timestamp": "2025-10-10T22:30:00Z",
  "regenesis": {
    "fast_path": {
      "startup_ms": 42,
      "message_latency_ms": 8,
      "memory_mb": 87
    },
    "true_path": {
      "nock_reduction_steps": 15420,
      "nock_eval_ms": 450,
      "equivalence_coverage_pct": 73
    },
    "verification": {
      "outputs_match": true,
      "golden_vectors_passed": 100,
      "golden_vectors_total": 100
    }
  }
}

These metrics get appended to docs/PROGRESS-SUMMARY.md automatically!

The First Ritual (Onboarding)

For newcomers, the Regenesis ritual is initiation:

Step 1: Clone the Valley

git clone https://codeberg.org/kae3g/12025-10
cd 12025-10

Step 2: Run Regenesis

./valley regenesis

What happens:

  1. Builds everything (Nix ensures reproducibility)
  2. Starts all services (Nostr, Urbit, UI)
  3. Sends first message through complete stack
  4. You see it working (browser opens to UI)
  5. Metrics written (proof it ran!)

Step 3: Verify

bb regenesis:verify
# ✓ Fast path and true path produce same noun
# ✓ All golden test vectors pass
# ✓ Equivalence maintained

Output:

The valley regenerates.
Your first noun recomputes.
Fast path: 42ms startup, 8ms latency
True path: 15,420 reduction steps, equivalence ✓
Welcome, valley builder. 🌱🔷

This makes the abstract TACTILE - you FEEL Nock regenerating!

Clojure Spec Throughout

Every layer uses Spec for contracts and verification:

Why Spec?

Even the Regenesis script itself is spec'd!

;; From scripts/regenesis.bb
(s/def ::startup-ms pos-int?)
(s/def ::fast-path (s/keys :req-un [::startup-ms ::message-latency-ms ::memory-mb]))
(s/def ::report (s/keys :req-un [::timestamp ::regenesis]))

;; Validation built into script!
(when-not (s/valid? ::report report)
  (throw (ex-info "Invalid metrics!" {:explain (s/explain-str ::report report)})))

Nostr Events

(require '[clojure.spec.alpha :as s])

;; Event structure
(s/def ::id string?)
(s/def ::pubkey string?)
(s/def ::created-at int?)
(s/def ::kind int?)
(s/def ::tags (s/coll-of vector?))
(s/def ::content string?)
(s/def ::sig string?)

(s/def ::event
  (s/keys :req-un [::id ::pubkey ::created-at ::kind ::tags ::content ::sig]))

;; Validation
(defn valid-event? [event]
  (s/valid? ::event event))

;; Generative testing
(require '[clojure.spec.gen.alpha :as gen])
(gen/sample (s/gen ::event) 10)
; Generates 10 random valid events for testing!

Nock Nouns

;; Noun spec (atom or cell)
(s/def ::atom nat-int?)
(s/def ::cell (s/tuple ::noun ::noun))
(s/def ::noun (s/or :atom ::atom :cell ::cell))

;; Formula spec (Nock opcodes 0-11)
(s/def ::opcode #{0 1 2 3 4 5 6 7 8 9 10 11})
(s/def ::formula (s/tuple ::opcode (s/* ::noun)))

;; Validation
(defn valid-noun? [n]
  (s/valid? ::noun n))

API Contracts

;; Function spec
(s/fdef filter-by-kind
  :args (s/cat :events (s/coll-of ::event)
               :kind-target ::kind)
  :ret (s/coll-of ::event)
  :fn (fn [{:keys [args ret]}]
        ; Property: All returned events have target kind
        (every? #(= (:kind %) (:kind-target args)) ret)))

;; This spec enables:
;; - Compile-time checking
;; - Generative testing
;; - Runtime validation
;; - Documentation!

Current Status

✅ Complete (Documentation)

🚧 In Progress (Implementation)

📋 Next Steps

  1. Implement Babashka Nock interpreter (12 rules!)
  2. Create first Nock Kata (compute *[[42 17] 0 2])
  3. Build Nostr relay with Spec contracts
  4. Wire Regenesis script
  5. Run and measure!

The Valley Theorem (Formal Statement)

Declared in docs/PROGRESS-SUMMARY.md:

The Valley Theorem

For any computational intent ( I ) expressed in the high-level stack (Clojure, ClojureScript, Nostr, Urbit), there exists a path-preserving transformation ( \tau ) to the Nock base specification such that:

  1. Semantic Equivalence: ( \text{eval}{\text{Clojure}}(I) \equiv \text{eval}{\text{Nock}}(\tau(I)) )
  2. Environmental Independence: Equivalence holds under all perturbations (hardware changes, time, network)
  3. Verifiability: The transformation ( \tau ) is auditable and provable

    Proof Strategy: Demonstrate equivalence through:

  4. Clojure Spec contracts (type-level properties)
  5. Golden test vectors (extensional equality)
  6. Nock reductions (intensional equality)
  7. Formal verification (Haskell → Liquid Haskell proofs)

This frames the entire project as a PROOF-SEEKING MISSION! 🔷

Links

The valley regenerates. The proof unfolds. The cycle is eternal. 🔄🌱🔷

Copyright © 2025 kae3g | Dual-licensed under Apache-2.0 / MIT
Competitive technology in service of clarity and beauty


← back to index