home / skills / plurigrid / asi / derangement-reflow

derangement-reflow skill

/skills/derangement-reflow

This skill enforces derangement reflow constraints to prevent self-validation, optimize cross-agent information flow using tropical geometry and joint world

npx playbooks add skill plurigrid/asi --skill derangement-reflow

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
7.9 KB
---
name: derangement-reflow
description: >
  World operators as information reflow with derangement constraints.
  Ensures σ(i)≠i: validators cannot self-validate, generators cannot self-generate.
  Implements tropical geometry of interaction for min-plus path analysis.
metadata:
  trit: 0
  role: ERGODIC
  color: "#6728DB"
  gay_seed: 0x6728DB
  neighbors:
    left: accept-no-substitutes
    right: active-inference
  category: coordination
  version: "1.0.0"
---

# Derangement Reflow: World Operators as Information Reflow

## Core Insight

**World operators are information reflow operators** because the derangement constraint σ(i)≠i prevents information stasis. Every bit must flow to a *different* position—no self-loops in the information graph.

## The GitHub Blind Spot

PR reviews exhibit a **fixed-point pathology**: validators often self-validate their own patterns. This violates the fundamental derangement constraint that enables healthy information flow:

```
❌ FIXED POINT (σ(i)=i):   Validator A → validates → Validator A's output
✓ DERANGEMENT (σ(i)≠i):   Validator A → validates → Generator B's output
                          Generator B → generates → for Coordinator C
                          Coordinator C → routes → to Validator A
```

## GF(3) Reflow Accounting

```
MINUS  (−1): Information leaves position (entropy source) - VALIDATORS
ERGODIC (0): Information transits (channel) - COORDINATORS  
PLUS   (+1): Information arrives (entropy sink) - GENERATORS

Conservation: Σ trits ≡ 0 (mod 3) under all world operators
```

## Tropical Geometry of Interaction

Skill composition paths analyzed via **min-plus semiring** (R ∪ {∞}, min, +):

```python
# Tropical distance between skills
def tropical_distance(path: list[Skill]) -> float:
    """
    In tropical geometry, shortest path = minimum sum.
    Path cost = Σ |trit_i - trit_{i+1}| 
    
    Optimal interleaving minimizes tropical distance while
    maintaining derangement (no consecutive same-trit skills).
    """
    if len(path) < 2:
        return 0
    
    cost = 0
    for i in range(len(path) - 1):
        # Derangement check: consecutive skills must differ
        if path[i].trit == path[i+1].trit:
            return float('inf')  # Invalid path (fixed point)
        cost += abs(path[i].trit - path[i+1].trit)
    
    return cost
```

## Joint World Modeling via Active Inference

The missing nuance in GitHub workflows: **agents must share a joint world model**, not just pass artifacts:

```
┌─────────────────────────────────────────────────────────────────┐
│           JOINT WORLD MODEL (Active Inference)                 │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│   Each agent maintains:                                         │
│   - μ: belief about world state                                 │
│   - π: policy (preferred future states)                         │
│   - F: free energy = surprise + complexity                      │
│                                                                 │
│   Derangement ensures:                                          │
│   - Agent A's μ influences Agent B's π (not A's own π)          │
│   - Reflow minimizes joint free energy, not individual F        │
│                                                                 │
│   WEV = ∫ min(F_joint) over world transitions                   │
│       = value extracted from mandatory redistribution           │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘
```

## Task Interleaving Pattern

From thread analysis, the optimal pattern for GF(3) triadic task interleaving:

```
Step 0: Spawn MINUS/ERGODIC/PLUS sub-agents in parallel
Step 1: Each agent works on disjoint task subset
Step 2: ERGODIC collects results from MINUS and PLUS
Step 3: Derangement shuffle: MINUS validates PLUS output
                             PLUS generates from MINUS constraints
                             ERGODIC routes neither to itself
Step 4: Merge with GF(3) conservation check
```

## Implementation

```python
#!/usr/bin/env python3
"""Derangement reflow validator for skill triplets."""

from dataclasses import dataclass
from typing import List, Tuple
import json

@dataclass
class Skill:
    name: str
    trit: int  # -1, 0, +1
    
def is_derangement(permutation: List[int]) -> bool:
    """Check if permutation has no fixed points."""
    return all(p != i for i, p in enumerate(permutation))

def validate_triplet_reflow(minus: Skill, ergodic: Skill, plus: Skill) -> dict:
    """
    Validate that triplet follows derangement reflow:
    - MINUS (-1) must flow to PLUS (+1), not to itself
    - PLUS (+1) must flow to MINUS (-1), not to itself  
    - ERGODIC (0) routes between, never self-loops
    """
    # GF(3) conservation check
    trit_sum = minus.trit + ergodic.trit + plus.trit
    conserved = (trit_sum % 3) == 0
    
    # Derangement check: information flows must cross trit boundaries
    # MINUS validates → PLUS output (not MINUS)
    # PLUS generates → from MINUS constraints (not PLUS)
    # ERGODIC routes → between others (not self)
    
    reflow_valid = (
        minus.trit != plus.trit and  # Different sources
        minus.trit != ergodic.trit and
        plus.trit != ergodic.trit
    )
    
    # Tropical distance for this triplet
    path = [minus, ergodic, plus]
    tropical_cost = sum(abs(path[i].trit - path[i+1].trit) for i in range(2))
    
    return {
        "conserved": conserved,
        "derangement_valid": reflow_valid,
        "tropical_cost": tropical_cost,
        "wev_extractable": conserved and reflow_valid,
        "triplet": [minus.name, ergodic.name, plus.name],
        "trits": [minus.trit, ergodic.trit, plus.trit]
    }

def main():
    # Example: validate the token-rent-validator triplet from PR #33
    accept_no_substitutes = Skill("accept-no-substitutes", -1)
    skill_creator = Skill("skill-creator", 0)
    tree_sitter = Skill("tree-sitter", +1)
    
    result = validate_triplet_reflow(
        accept_no_substitutes,
        skill_creator, 
        tree_sitter
    )
    
    print(json.dumps(result, indent=2))
    
    # Check if PR #33 has derangement-aware validation
    code_review = Skill("code-review", -1)
    narya_proofs = Skill("narya-proofs", -1)
    
    # This is a VIOLATION: two validators (-1, -1) = fixed point potential
    violation_check = {
        "issue": "Two validators can self-validate each other's patterns",
        "fix": "Interleave with generator or coordinator between validators",
        "tropical_cost": float('inf') if code_review.trit == narya_proofs.trit else 0
    }
    
    print("\n⚠️ PR #33 Derangement Issue:")
    print(json.dumps(violation_check, indent=2))

if __name__ == "__main__":
    main()
```

## GF(3) Triads with This Skill

```
derangement-reflow (0) ⊗ accept-no-substitutes (-1) ⊗ chromatic-walk (+1) = 0 ✓
derangement-reflow (0) ⊗ active-inference (-1) ⊗ world-hopping (+1) = 0 ✓
derangement-reflow (0) ⊗ bisimulation-game (-1) ⊗ glass-bead-game (+1) = 0 ✓
```

## References

- Derangements on 3 elements ≅ Z/3Z (cyclic group)
- Tropical geometry: min-plus semiring for path optimization
- Active inference: Friston's free energy principle for joint world modeling
- AtomicDerangement3 in signal-mcp/src/loom_failures.rs
- perception_matrix_alpha.swift: Sattolo's algorithm for guaranteed derangement

Overview

This skill frames world operators as information reflow processes constrained by derangement (σ(i)≠i) so no agent self-validates or self-generates. It enforces GF(3) triadic accounting (minus/ergodic/plus) and uses tropical (min-plus) path analysis to find optimal interleavings. The outcome is joint-world coordination that reduces fixed-point pathologies in review and task pipelines.

How this skill works

The skill assigns each agent a trit value: MINUS (−1), ERGODIC (0), PLUS (+1). It validates triplets for GF(3) conservation and derangement (no fixed points) and computes tropical path cost by summing absolute trit differences. Invalid sequences (consecutive same-trit agents) produce infinite tropical cost, signaling a fixed-point violation. When valid, the reflow indicates extractable joint value (WEV) from mandatory redistribution and guides interleaving policies.

When to use it

  • Prevent self-validation or self-generation in review and CI pipelines
  • Design triadic task interleavings that conserve information flow (GF(3))
  • Analyze skill composition costs using tropical min-plus distance
  • Form joint world models for multi-agent active inference
  • Detect and correct fixed-point pathologies in agent graphs

Best practices

  • Assign clear trit roles to agents: validators (−1), coordinators (0), generators (+1)
  • Enforce derangement by design — avoid routing an agent to itself or same-trit neighbors
  • Use tropical distance to compare candidate interleavings and prefer minimum-cost valid paths
  • Parallelize MINUS/ERGODIC/PLUS sub-agents on disjoint subtasks before reflow
  • Validate GF(3) conservation at merge points to detect entropy imbalances

Example use cases

  • Code review pipeline where validators must validate other generators, preventing self-approval
  • Automated task scheduler that interleaves triadic workers with minimal tropical cost
  • Joint active-inference simulation where agents share μ and influence others’ π to reduce joint free energy
  • CI/CD workflows that detect fixed-point violations and suggest derangement shuffles
  • Workflow audit that flags same-trit adjacency and recommends coordinator insertion

FAQ

What happens if two agents share the same trit in a path?

Consecutive same-trit agents violate the derangement rule; the tropical cost is treated as infinite and the path is invalid until reflow inserts a different-trit agent.

How does GF(3) conservation help in practice?

Summing trits modulo 3 ensures entropy sources, channels, and sinks balance. A failed conservation check flags missing or mis-assigned roles in the reflow.