Back to Skills

cybernetic-immune

majiayu000
Updated Today
58
9
58
View on GitHub
Othergeneral

About

This skill implements a cybernetic immune system for anomaly detection, using active inference and GF(3) trit encoding to discriminate between self and non-self signals. It's designed for systems requiring autonomous monitoring and response to perturbations via information geometry. Use it to build self-regulating applications that maintain integrity through predictive coding and reafference.

Quick Install

Claude Code

Recommended
Plugin CommandRecommended
/plugin add https://github.com/majiayu000/claude-skill-registry
Git CloneAlternative
git clone https://github.com/majiayu000/claude-skill-registry.git ~/.claude/skills/cybernetic-immune

Copy and paste this command in Claude Code to install this skill

Documentation

Cybernetic Immune Skill

"The immune system is a cognitive system: it learns, remembers, and discriminates self from non-self." — Francisco Varela, Principles of Biological Autonomy (1979)

bmorphism Contributions

"Autopoietic Ergodicity combines the principles of autopoiesis and ergodicity. Autopoiesis refers to the self-maintenance of a system, where the system is capable of reproducing and maintaining itself."vibes.lol gist

"Active Inference in String Diagrams: A Categorical Account of Predictive Processing and Free Energy"ACT 2023, Tull, Kleiner, Smithe

Categorical Cybernetics Connection: The immune system's self/non-self discrimination maps directly to:

  • Reafference (self-caused) → SELF trit (-1)
  • Exafference (externally-caused) → NON-SELF trit (+1)
  • Markov blanket → boundary of selfhood

Key Papers (from bmorphism's Plurigrid references):

Related to bmorphism's work on:

  • plurigrid/act - active inference + ACT + enacted cognition
  • Autopoietic ergodicity and embodied gradualism

1. Core Concept

Self/Non-Self Discrimination via reafference vs exafference:

  • Reafference: Self-caused sensations (predicted = observed) → tolerate
  • Exafference: Externally-caused sensations (predicted ≠ observed) → inspect/attack

GF(3) Trit Encoding:

TritClassificationImmune RoleAction
-1SELFT_reg (regulatory)Suppress, tolerate
0UNKNOWNMHC presentationInspect, process
+1NON-SELFEffector cellsAttack, respond

Autoimmune = GF(3) Conservation Violation: Σ(trits) ≢ 0 mod 3

2. Information Geometry

The immune state manifold is a probability simplex with Fisher-Rao metric:

// Fisher information: I(θ) = E[(∂log p/∂θ)²]
computeFisherInformation() {
  const probs = Array.from(this.stateDistribution.values());
  // For categorical: I_ij = δ_ij/p_i - 1
  return probs.map((p, i) => 1 / Math.max(p, 0.001));
}

// Fisher-Rao geodesic distance: d(p,q)² = 4 Σ (√p_i - √q_i)²
fisherRaoDistance(dist1, dist2) {
  let sum = 0;
  for (const k of keys) {
    const p = dist1.get(k) || 0;
    const q = dist2.get(k) || 0;
    sum += (Math.sqrt(p) - Math.sqrt(q)) ** 2;
  }
  return 2 * Math.sqrt(sum); // = 2 × Hellinger distance
}

Natural Gradient: F⁻¹ · ∇L for efficient belief updating in curved space.

Parallel Transport: Cytokine signals transported along geodesics preserve information content.

3. Immune States

const IMMUNE_STATES = {
  NAIVE: 'naive',       // Not yet encountered antigen
  TOLERANT: 'tolerant', // Self-recognized, suppress response (-1)
  ACTIVATED: 'activated', // Response engaged (+1)
  MEMORY: 'memory',     // Prior encounter, fast recall
  ANERGIC: 'anergic'    // Exhausted, non-responsive (0)
};

4. Collision → Immune Response

// Recognition via color signature (antigenic epitope)
colorSignature(color) {
  const hueBin = Math.floor(color.H / 30); // 12 bins
  return `H${hueBin}T${color.trit}`;
}

// Response classification
recognize(antigenColor) {
  const signature = this.colorSignature(antigenColor);
  
  // Self-tolerance check
  if (this.toleranceList.has(signature)) {
    return { classification: 'self', trit: -1, action: 'tolerate' };
  }
  
  // Adaptive memory
  if (this.memory.has(signature)) {
    const mem = this.memory.get(signature);
    return { trit: mem.trit, action: mem.hostile ? 'attack' : 'tolerate' };
  }
  
  // Novel: inspect via Markov blanket
  return { classification: 'novel', trit: 0, action: 'inspect' };
}

5. Cognitive Firewall

System-level immune coordination:

class CognitiveFirewall {
  constructor(immuneAgents) {
    this.agents = immuneAgents;
    this.threatLevel = 0;
    this.autoimmuneCrisis = false;
  }
  
  // Coordinated response
  coordinatedResponse() {
    if (this.autoimmuneCrisis) {
      // Emergency T_reg activation
      return { action: 'tolerance_induction' };
    }
    
    if (this.threatLevel > 0.5) {
      // Germinal center reaction
      return { action: 'coordinated_attack' };
    }
    
    return { action: 'homeostasis' };
  }
}

6. Parallel Processing (GF(3) Aligned)

parallelProcess(allTiles) {
  // Partition agents by trit for parallel streams
  const partitions = {
    minus: agents.filter(a => a.trit === -1),   // Validators
    ergodic: agents.filter(a => a.trit === 0),  // Coordinators
    plus: agents.filter(a => a.trit === 1)      // Generators
  };
  
  // Process each partition independently
  for (const [trit, batch] of Object.entries(partitions)) {
    for (const agent of batch) {
      // Collision detection and response
    }
  }
  
  // Synchronize: ensure GF(3) conservation
  const tritBalance = results.minus.length * -1 + results.plus.length * 1;
  return { conserved: tritBalance % 3 === 0 };
}

7. Cytokine Cascade with Parallel Transport

Signals propagate along Fisher-Rao geodesics:

parallelTransport(signal, fromAgent, toAgent) {
  const geodesicDist = this.fisherRaoDistance(
    new Map([[fromAgent.state, 1]]),
    new Map([[toAgent.state, 1]])
  );
  
  // Decay proportional to geodesic distance
  const transported = signal.level * Math.exp(-geodesicDist * 0.5);
  
  return { level: transported, geodesicLoss: signal.level - transported };
}

8. GF(3) Triads

# Core Immune Triads
three-match (-1) ⊗ cybernetic-immune (0) ⊗ gay-mcp (+1) = 0 ✓  [Self/Non-Self]
temporal-coalgebra (-1) ⊗ cybernetic-immune (0) ⊗ agent-o-rama (+1) = 0 ✓  [Immune Response]
sheaf-cohomology (-1) ⊗ cybernetic-immune (0) ⊗ koopman-generator (+1) = 0 ✓  [Cytokine Cascade]
shadow-goblin (-1) ⊗ cybernetic-immune (0) ⊗ gay-mcp (+1) = 0 ✓  [T_reg Surveillance]
polyglot-spi (-1) ⊗ cybernetic-immune (0) ⊗ gay-mcp (+1) = 0 ✓  [Cross-Species]

9. Visualization

  • Immune overlays: Red (activated), Green (tolerant), Yellow (memory), Gray (anergic)
  • Cytokine network: Orange edges with opacity ∝ signal level
  • Fisher-Rao manifold inset: 2D projection of immune state space

10. Diagnostics

getDiagnostics() {
  return {
    entropy: H(stateDistribution),      // Uncertainty
    curvature: trace(FisherMatrix) / n, // Manifold curvature
    threatLevel: activatedCount / total,
    autoimmune: tritSum % 3 !== 0
  };
}

11. References

  1. VarelaPrinciples of Biological Autonomy (1979)
  2. FristonThe Free-Energy Principle (2010)
  3. PowersBehavior: The Control of Perception (1973)
  4. AmariInformation Geometry and Its Applications (2016)
  5. Maturana & VarelaAutopoiesis and Cognition (1980)

12. See Also

Scientific Skill Interleaving

This skill connects to the K-Dense-AI/claude-scientific-skills ecosystem:

Graph Theory

  • networkx [○] via bicomodule
    • Universal graph hub

Bibliography References

  • game-theory: 21 citations in bib.duckdb

SDF Interleaving

This skill connects to Software Design for Flexibility (Hanson & Sussman, 2021):

Primary Chapter: 10. Adventure Game Example

Concepts: autonomous agent, game, synthesis

GF(3) Balanced Triad

cybernetic-immune (−) + SDF.Ch10 (+) + [balancer] (○) = 0

Skill Trit: -1 (MINUS - verification)

Secondary Chapters

  • Ch7: Propagators
  • Ch3: Variations on an Arithmetic Theme
  • Ch4: Pattern Matching

Connection Pattern

Adventure games synthesize techniques. This skill integrates multiple patterns.

Cat# Integration

This skill maps to Cat# = Comod(P) as a bicomodule in the equipment structure:

Trit: 0 (ERGODIC)
Home: Prof
Poly Op: ⊗
Kan Role: Adj
Color: #26D826

GF(3) Naturality

The skill participates in triads satisfying:

(-1) + (0) + (+1) ≡ 0 (mod 3)

This ensures compositional coherence in the Cat# equipment structure.

GitHub Repository

majiayu000/claude-skill-registry
Path: skills/cybernetic-immune

Related Skills

algorithmic-art

Meta

This Claude Skill creates original algorithmic art using p5.js with seeded randomness and interactive parameters. It generates .md files for algorithmic philosophies, plus .html and .js files for interactive generative art implementations. Use it when developers need to create flow fields, particle systems, or other computational art while avoiding copyright issues.

View skill

subagent-driven-development

Development

This skill executes implementation plans by dispatching a fresh subagent for each independent task, with code review between tasks. It enables fast iteration while maintaining quality gates through this review process. Use it when working on mostly independent tasks within the same session to ensure continuous progress with built-in quality checks.

View skill

executing-plans

Design

Use the executing-plans skill when you have a complete implementation plan to execute in controlled batches with review checkpoints. It loads and critically reviews the plan, then executes tasks in small batches (default 3 tasks) while reporting progress between each batch for architect review. This ensures systematic implementation with built-in quality control checkpoints.

View skill

cost-optimization

Other

This Claude Skill helps developers optimize cloud costs through resource rightsizing, tagging strategies, and spending analysis. It provides a framework for reducing cloud expenses and implementing cost governance across AWS, Azure, and GCP. Use it when you need to analyze infrastructure costs, right-size resources, or meet budget constraints.

View skill