world-replay-buffer

Maximally snapshotted replay buffer with DuckLake embedding VSS and moments of interaction for world-transition storage

16 stars

Best use case

world-replay-buffer is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Maximally snapshotted replay buffer with DuckLake embedding VSS and moments of interaction for world-transition storage

Teams using world-replay-buffer should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/world-replay-buffer/SKILL.md --create-dirs "https://raw.githubusercontent.com/plurigrid/asi/main/plugins/asi/skills/world-replay-buffer/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/world-replay-buffer/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How world-replay-buffer Compares

Feature / Agentworld-replay-bufferStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Maximally snapshotted replay buffer with DuckLake embedding VSS and moments of interaction for world-transition storage

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# World Replay Buffer

**Trit**: 0 (ZERO)
**Domain**: Reinforcement Learning / World Transitions
**Principle**: Worlds (a-z) as successor worlds with GF(3) balanced sampling

## Overview

A maximally snapshotted replay buffer system for storing and retrieving world-transitions with:
- **DuckDB persistence** with vector similarity search (VSS)
- **GF(3) Galois Field classification** {-1=MINUS, 0=ZERO, +1=PLUS}
- **Trit-tick timing** at 1/141,120,000 second (~7.09 ns) precision
- **Content-addressed deduplication** via SHA-256 hashing
- **Play/Coplay Arena semantics** for action-observation pairs

## Mathematical Definition

```
REPLAY: WorldState × Action → WorldState' × Observation × Reward
GF3_COLOR: Experience → {-1, 0, +1}
TRIT_TICK: 1 / 141_120_000 seconds ≈ 7.09 nanoseconds
```

## Architecture

```
┌─────────────────────────────────────────────────────────┐
│                   World Replay Buffer                    │
├─────────────────────────────────────────────────────────┤
│  replay_buffer.lpy    │ Pure Basilisp in-memory buffer  │
│  replay_buffer.py     │ Python + DuckDB/VSS persistence │
│  replay_orchestrator.py│ Unified orchestrator with DB   │
│  replay_bridge.lpy    │ Basilisp-Python interop bridge  │
└─────────────────────────────────────────────────────────┘
```

## Key Components

### 1. Experience Storage

```clojure
;; Basilisp experience structure
{:world-from "world-a"
 :world-to   "world-b"
 :action     {:play [:move :forward]}
 :obs        {:coplay [:sensor :reading]}
 :reward     1.0
 :timestamp  1711471200.0
 :gf3-color  1}  ; PLUS
```

### 2. GF(3) Classification

Uses SplitMix64 deterministic hashing for reproducible coloring:

```python
def gf3_color(content: str) -> int:
    """GF(3) classification via SplitMix64 hash."""
    h = splitmix64_hash(content)
    return (h % 3) - 1  # {-1, 0, +1}
```

### 3. World Transitions

Worlds are labeled a-z as **successor worlds**, NOT todos:

```
world-a → world-b → world-c → ... → world-z
```

Each transition stores:
- Source world state
- Action taken (play)
- Resulting observation (coplay)
- Reward signal
- GF(3) color for balanced sampling

### 4. Prioritized Sampling

Balanced sampling across GF(3) classes ensures no class dominates:

```clojure
(defn sample-balanced-gf3
  "Sample experiences balanced across GF(3) classes."
  [buffer n]
  (let [by-color (group-by :gf3-color buffer)
        per-class (max 1 (quot n 3))]
    (->> (vals by-color)
         (mapcat #(take per-class (shuffle %)))
         (take n))))
```

## DuckDB Schema

```sql
CREATE SEQUENCE IF NOT EXISTS exp_id_seq;
CREATE TABLE IF NOT EXISTS experiences (
    id INTEGER PRIMARY KEY DEFAULT nextval('exp_id_seq'),
    world_from TEXT NOT NULL,
    world_to TEXT NOT NULL,
    action_json TEXT NOT NULL,
    obs_json TEXT NOT NULL,
    reward DOUBLE NOT NULL,
    timestamp_ns BIGINT NOT NULL,
    gf3_color INTEGER NOT NULL,
    content_hash TEXT UNIQUE NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_gf3 ON experiences(gf3_color);
CREATE INDEX IF NOT EXISTS idx_world_from ON experiences(world_from);
```

## Usage

### Basilisp (Pure In-Memory)

```clojure
(ns replay-buffer)

;; Add experience
(def exp {:world-from "world-a"
          :world-to "world-b"
          :action {:type :move}
          :obs {:type :sensor}
          :reward 1.0})
(add-experience! buffer exp)

;; Sample balanced
(sample-balanced-gf3 @buffer 10)
```

### Python (With Persistence)

```python
from replay_orchestrator import ReplayOrchestrator

orch = ReplayOrchestrator()
orch.store_experience(
    world_from="world-a",
    world_to="world-b",
    action={"type": "move"},
    observation={"type": "sensor"},
    reward=1.0
)
samples = orch.sample_balanced(n=10)
```

### Basilisp-Python Bridge

```clojure
(ns replay-bridge
  (:import importlib))

(def orch (get-orchestrator))
(store-experience! orch {:world-from "world-a" ...})
```

## Integration with GF(3)

This skill participates in triadic composition:
- **Trit 0** (ZERO): Neutral/balanced storage
- **Conservation**: Σ trits ≡ 0 (mod 3) across skill triplets
- **Balanced Sampling**: Equal representation of {-1, 0, +1} classes

## Trit-Tick Timing

```python
TRIT_TICK = 1 / 141_120_000  # ~7.09 nanoseconds
timestamp_tritticks = int(time.time() / TRIT_TICK)
```

## Files

Located in `/Users/alice/worlds/`:
- `replay_buffer.lpy` - Pure Basilisp implementation
- `replay_buffer.py` - Python with DuckDB
- `replay_orchestrator.py` - Unified orchestrator
- `replay_bridge.lpy` - Basilisp-Python bridge

## Related Skills

- world-hopping (trit +1) - Navigate between worlds
- worlding (trit -1) - World construction
- trajectory (trit -1) - Path through phase space
- gf3-classification (trit 0) - Triadic classification
- ducklake (trit +1) - DuckDB lakehouse

---

**Skill Name**: world-replay-buffer
**Type**: Reinforcement Learning / Experience Storage
**Trit**: 0 (ZERO)
**GF(3)**: Conserved in triplet composition

## Non-Backtracking Geodesic Qualification

**Condition**: μ(n) ≠ 0 (Mobius squarefree)

This skill is qualified for non-backtracking geodesic traversal:

1. **Prime Path**: No world revisited in transition chain
2. **Mobius Filter**: Composite paths (backtracking) cancel via μ-inversion
3. **GF(3) Conservation**: Trit sum ≡ 0 (mod 3) across skill triplets
4. **Content Dedup**: SHA-256 ensures no duplicate experiences

```
Geodesic Invariant:
  ∀ path P: backtrack(P) = ∅ ⟹ μ(|P|) ≠ 0
  
World Transition:
  world_a →[action]→ world_b →[action]→ world_c
  
GF(3) Balance:
  |{exp : color = -1}| ≈ |{exp : color = 0}| ≈ |{exp : color = +1}|
```

Related Skills

worldmat-tidar

16
from plurigrid/asi

worldmat-tidar

worlding

16
from plurigrid/asi

Gay.jl world_ pattern: persistent composable state builders with GF(3) conservation, Möbius invertibility, and Narya verification

worlding-calendar

16
from plurigrid/asi

Calendar events tied to 26 letter-worlds via org-mode. Links events to beeper messages, voice notes, and Goblins capabilities. Replaces 13K-token Google Calendar MCP with CalDAV + DuckDB interactome.

world-sufficiency-prompt

16
from plurigrid/asi

First-interaction system prompt generator for Gemini, Codex, and Claude. Detects hierarchical user intent (implicit and explicit) and loads GF(3)-balanced skill triads to achieve World -> World' sufficiency before any model response. Bridges dynamic-sufficiency theory to concrete systemInstruction/system-message payloads across all three providers.

world-runtime

16
from plurigrid/asi

Firecracker microVM + Morph Infinibranch WorldRuntime for parallel verse execution. Entities branch/snapshot in <250ms.

world-memory-worlding

16
from plurigrid/asi

World memory is world remembering is world worlding - the autopoietic loop where memory enables remembering enables worlding enables memory

world-extractable-value

16
from plurigrid/asi

Extract value from world transitions via Markov blanket arbitrage. WEV = PoA - 1. Paradigm Multiverse Finance integration.

nix-acset-worlding

16
from plurigrid/asi

Model Nix store as Attributed C-Set for dependency verification, GC analysis,

braindance-worlds

16
from plurigrid/asi

GF(3)-conserved distribution of Claude threads across Aptos worlds

world-hopping

16
from plurigrid/asi

Badiou-inspired possible world navigation using triangle inequality constraints, event ontology, and truth procedures for traversing mathematical possibility space.

unworlding-involution

16
from plurigrid/asi

Self-inverse derivation patterns where ι∘ι = id for frame-invariant self

unworld

16
from plurigrid/asi

Replace temporal succession with derivational chains using deterministic seeds and GF(3) invariants.