# Plurigrid Polyglot

> Polyglot skill orchestration system integrating Go, Clojure, Hy, and Zig. Provides skill discovery, GF(3) validation, cross-language dispatch, and pluralistic consensus. Use for coordinating multi-language skill ecosystems and maintaining GF(3) conservation across polyglot systems.

- Skill: `plurigrid/plurigrid-polyglot` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add plurigrid/plurigrid-polyglot`
- Raw SKILL.md: https://api.skillmd.com/api/skills/plurigrid/plurigrid-polyglot/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Product & Planning
- License: MIT
- Author: plurigrid (https://skillmd.com/u/plurigrid)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/plurigrid/plurigrid-polyglot

---


# plurigrid-polyglot - Polyglot Skill Orchestration

## Overview

**plurigrid-polyglot** coordinates diverse skill ecosystems across multiple programming languages, maintaining GF(3) conservation laws and enabling triadic consensus. It provides the infrastructure for pluralistic scientific skill interfaces (SCI) where validators, coordinators, and generators work together regardless of implementation language.

**Role**: Universal ERGODIC coordinator - bridges all language-specific skills in a coherent GF(3) framework.

## Architecture

### Language Ecosystem

```
                  plurigrid-polyglot
                         │
        ┌────────────────┼────────────────┬──────────────┐
        │                │                │              │
    [joker]        [jo-clojure]      [hy-regime]   [zig-systems]
      (Go)          (Clojure)        (Hylang)         (Zig)
    MINUS(-1)      ERGODIC(0)        PLUS(+1)       ERGODIC(0)
   Validator      Coordinator       Generator      Coordinator
       │                │               │              │
       └────────────────┴───────────────┴──────────────┘
                        │
                 GF(3) Conservation
                ∑ trits ≡ 0 (mod 3)
```

### Skill Trit Assignment

| Skill | Language | Trit | Role | Domain |
|-------|----------|------|------|--------|
| **joker-sims-parser** | Go | -1 | Validator | File format validation |
| **jo-clojure** | Clojure | 0 | Coordinator | JVM ecosystem, skill routing |
| **hy-regime** | Hy | +1 | Generator | Message analysis, prediction |
| **zig-systems** | Zig | 0 | Coordinator | Systems performance, low-level |

### GF(3) Balance Principle

Every composition maintains:
```
∑ trits ≡ 0 (mod 3)

Examples:
  joker(-1) + jo-clojure(0) + hy-regime(+1) = 0 ✓
  joker(-1) + zig-systems(0) + [new-gen(+1)] = 0 ✓
  Multiple coordinators allowed in different domains
```

## Skill Discovery

### List All Skills

```bash
plurigrid list-skills /Users/bob/i/boxxy/skills
```

Output:
```
Skill                 Language  Trit    Role         Status
────────────────────────────────────────────────────────────────
joker-sims-parser     Go        -1      Validator    ✓ Ready
jo-clojure           Clojure    0       Coordinator  ✓ Ready
hy-regime            Hy         +1      Generator    ✓ Ready
zig-systems          Zig        0       Coordinator  ✓ Ready
```

### Validate GF(3) Balance

```bash
plurigrid validate-triad joker-sims-parser jo-clojure hy-regime
```

Output:
```
Triad Validation
────────────────────────────────
Skills:    [joker-sims-parser, jo-clojure, hy-regime]
Trits:     [-1, 0, +1]
Sum:       0 ✓ BALANCED
Status:    ✓ GF(3) conservative
```

## Cross-Language Dispatch

### Generic Skill Invocation

```bash
plurigrid invoke <skill> <command> [args...]

# Examples:
plurigrid invoke joker-sims-parser parse ~/save.sims3pack
plurigrid invoke jo-clojure list-skills
plurigrid invoke hy-regime analyze batch.txt
plurigrid invoke zig-systems compress input.dat
```

### Dispatch Logic

1. **Discover skill** in `/skills/<name>/SKILL.md`
2. **Determine language** from metadata or shebang
3. **Select executor**:
   - Go: Call binary directly
   - Clojure: Run with `clojure`
   - Hy: Run with `hy`
   - Zig: Execute compiled binary
4. **Route arguments** appropriately
5. **Capture output** and return

### Implementation Pattern

```go
// Pseudocode for dispatcher
type SkillDispatch struct {
    Name     string
    Language string
    Binary   string
    Args     []string
}

func (d SkillDispatch) Invoke() (string, error) {
    switch d.Language {
    case "go":
        return shell.Execute(d.Binary, d.Args...)
    case "clojure":
        return shell.Execute("clojure", append([]string{"-X", d.Binary}, d.Args...)...)
    case "hy":
        return shell.Execute("hy", append([]string{d.Binary}, d.Args...)...)
    case "zig":
        return shell.Execute(d.Binary, d.Args...)
    }
}
```

## Polyglot Composition Patterns

### Pattern 1: Validator → Coordinator → Generator Pipeline

```bash
# Validate Sims file (joker)
plurigrid invoke joker-sims-parser parse save.sims3pack > validation.json

# Coordinate JVM skills (jo-clojure)
plurigrid invoke jo-clojure process-result validation.json > coordination.json

# Generate predictions (hy-regime)
plurigrid invoke hy-regime predict coordination.json > predictions.json
```

### Pattern 2: Parallel Coordinator Invocation

```bash
# Get system stats via Zig
plurigrid invoke zig-systems bench input.dat > perf.json &

# Analyze regime via Hy
plurigrid invoke hy-regime analyze batch.txt > regime.json &

# Coordinate results (Clojure)
plurigrid invoke jo-clojure merge perf.json regime.json
```

### Pattern 3: Language Bridging

```bash
# Output from Go skill
joker parse file.sims3pack | \
  # Pipe to Clojure coordinator
  clojure -e "(require '[clojure.data.json]) (json/parse)" | \
  # Send to Hy for prediction
  hy -e "(analyze (read-json))"
```

## Color Generation

Maps skills to deterministic colors via Gay.jl:

```
joker-sims-parser    → #FF4444 (red,    trit -1, validator)
jo-clojure          → #44FF44 (green,  trit  0, coordinator)
hy-regime           → #4444FF (blue,   trit +1, generator)
zig-systems         → #FFFF44 (yellow, trit  0, secondary coordinator)
```

## Setup and Installation

### 1. Create Skill Directory Structure

```bash
mkdir -p /Users/bob/i/boxxy/skills/{joker-sims-parser,jo-clojure,hy-regime,zig-systems}
cd /Users/bob/i/boxxy/skills
```

### 2. Install Language Runtimes

```bash
# Go (for joker)
go version  # Should be 1.21+

# Clojure
clojure -version  # Should be 1.11+

# Hy
pip install hy==0.27.0

# Zig
brew install zig  # or download from ziglang.org

# Verify all
for lang in go clojure hy zig; do
  echo -n "$lang: " && which $lang || echo "NOT FOUND"
done
```

### 3. Build All Skills

```bash
# Go: joker
(cd /Users/bob/i/boxxy/cmd/joker && go build -o ../../bin/joker .)

# Clojure: verify installation
clojure -version

# Hy: verify installation
hy --version

# Zig: build (if needed)
cd zig-systems && zig build
```

### 4. Validate Skill Ecosystem

```bash
plurigrid validate-ecosystem /Users/bob/i/boxxy/skills
```

## Configuration

### Global Clojure Configuration

Update `~/.clojure/deps.edn`:

```edn
{
  :aliases {
    :skill-jvm {:extra-deps {org.clojure/clojure {:mvn/version "1.11.1"}
                             nrepl/nrepl {:mvn/version "0.9.1"}
                             cider/cider-nrepl {:mvn/version "0.28.4"}}}

    :gf3-validate {:extra-deps {org.clojure/clojure {:mvn/version "1.11.1"}
                                org.clojure/math.numeric-tower {:mvn/version "0.0.4"}}}
  }
}
```

### Environment Variables

```bash
# Add to ~/.zshrc or ~/.bashrc
export BOXXY_SKILLS_DIR="/Users/bob/i/boxxy/skills"
export BOXXY_BIN="/Users/bob/i/boxxy/bin"
export PATH="${BOXXY_BIN}:${PATH}"

# Clojure
export CLJ_CONFIG="~/.clojure"

# Hy
export HY_VERSION="0.27.0"

# Zig
export ZIG_CACHE_DIR="/tmp/zig-cache"
```

## When to Use

- **Coordinating multi-language systems**: Need Go, Clojure, Hy, Zig together
- **Maintaining GF(3) balance**: Ensuring skill triads are conservative
- **Skill discovery and routing**: Find and invoke skills by name
- **Pluralistic development**: Mix languages for their strengths
- **Triadic consensus validation**: Check group decision making
- **Cross-language FFI**: Call between different language runtimes

## When NOT to Use

- Single-language projects (use language-specific tools)
- Monolithic applications (better as single large project)
- Performance-critical hot paths (overhead from dispatch)
- Simple scripts (overkill for small tasks)

## Troubleshooting

### Skill Not Found

```bash
# Verify directory structure
ls /Users/bob/i/boxxy/skills/*/SKILL.md

# Check skill name matches directory
grep "^name:" /Users/bob/i/boxxy/skills/*/SKILL.md
```

### Language Runtime Not Available

```bash
# Check which runtimes are installed
for cmd in go clojure hy zig java python3; do
  which $cmd 2>/dev/null && echo "$cmd: $(($cmd --version 2>/dev/null || echo 'version unknown'))"
done
```

### GF(3) Validation Fails

```bash
# Check trit assignments
grep "gf3-trit:" /Users/bob/i/boxxy/skills/*/SKILL.md

# Manually sum
plurigrid validate-triad joker-sims-parser jo-clojure hy-regime
# Should output: Sum: 0 ✓ BALANCED
```

### Invocation Fails

```bash
# Test skill directly
plurigrid invoke joker-sims-parser help

# Check exit code
echo $?  # Should be 0 for success

# Enable verbose logging
PLURIGRID_DEBUG=1 plurigrid invoke <skill> <cmd>
```

## References

- [Skill System Architecture](references/SKILL_ARCHITECTURE.md)
- [GF(3) Theory and Implementation](references/GF3_CONSERVATION.md)
- [Cross-Language Dispatch Guide](references/DISPATCH_GUIDE.md)
- [Polyglot Composition Patterns](references/COMPOSITION_PATTERNS.md)
- [Performance Benchmarking](references/PERFORMANCE_GUIDE.md)

## Future Enhancements

### Phase 1: Foundation (Current)
- ✓ Go (joker)
- ✓ Clojure (jo-clojure)
- ✓ Hy (hy-regime)
- ✓ Zig (zig-systems)

### Phase 2: Extended Languages
- Python (numpy, scipy skills)
- Rust (performance-critical modules)
- Julia (numerical computation)
- Scheme (logic programming)
- WASM (web and edge deployment)

### Phase 3: Advanced Features
- Live skill hot-reloading
- Skill versioning and compatibility
- Distributed skill invocation (across machines)
- Skill marketplace and discoverability
- Runtime profiling and optimization

## Ecosystem Statistics

```
Total Skills:     4
Languages:        4 (Go, Clojure, Hy, Zig)
GF(3) Balance:    ✓ Conservative
Total LOC:        ~2500 (implementation)
Total Docs:       ~5000 lines (reference)
Build Time:       ~5 seconds
Binary Size:      ~10MB (all compiled skills)
Startup Time:     <100ms (avg)
```

---

**This skill is the keystone of Boxxy's plurigrid polyglot ecosystem. Use it to compose, validate, and orchestrate diverse skill systems while maintaining GF(3) conservation and scientific rigor.**

