Skip to content
gmail-anima logo

Gmail ANIMA Skill

gmail-anima

Gmail inbox management via ANIMA condensation. Transforms messages into GF(3)-typed Interactions, routes to triadic queues, detects saturation for inbox-zero-as-condensed-state. Use for email triage, workflow automation, or applying ANIMA principles to Gmail.

SKILL.md

Full skill instructions

Gmail ANIMA Skill

Transform Gmail into an ANIMA-condensed system with GF(3) conservation.

Trit: 0 (ERGODIC - coordinator)
Principle: Inbox Zero = Condensed Equilibrium State
Implementation: GmailACSet + TriadicQueues + AnimaDetector

Overview

Gmail ANIMA applies the ANIMA framework to email:

  1. Transform - Messages → GF(3)-typed Interactions
  2. Route - Interactions → Triadic queue fibers (MINUS/​ERGODIC/​PLUS)
  3. Detect - Saturation → ANIMA condensed state
  4. Verify - Narya proofs for consistency

GmailACSet Schema

┌────────────────────────────────────────────────────────────────────┐
│                      GmailACSet Schema                             │
├────────────────────────────────────────────────────────────────────┤
│                                                                    │
│  Interaction ─────┬────▶ Thread                                   │
│  ├─ verb: String  │      ├─ thread_id: String                     │
│  ├─ timebin: Int  │      ├─ needs_action: Bool                    │
│  ├─ trit: Trit    │      ├─ last_action_bin: Int                  │
│  └─ person ───────┼──▶   └─ saturated: Bool                       │
│                   │                                                │
│  QueueItem ───────┼────▶ Agent3                                   │
│  ├─ interaction ──┘      ├─ fiber: Trit {-1, 0, +1}               │
│  └─ agent ───────────▶   └─ name: String                          │
│                                                                    │
│  Person ◀─────────────── Partner ────────────────▶ Person         │
│  ├─ email: String        ├─ src                                   │
│  └─ name: String         ├─ tgt                                   │
│                          └─ weight: Int                            │
└────────────────────────────────────────────────────────────────────┘

Objects

ObjectDescriptionTrit Role
InteractionSingle email action with verb + tritData
ThreadGmail conversation with saturation stateAggregate
Agent3Queue fiber (MINUS/​ERGODIC/​PLUS)Router
QueueItemLinks Interaction → Agent3Edge
PersonEmail contactNode
PartnerRelationship edge in contact graphEdge

GF(3) Verb Typing

Gmail actions are assigned trits based on information flow:

VERB_TRIT_MAP = {
    # MINUS (-1): Consumption/​Validation
    "read": -1,      "search": -1,     "view": -1,
    "fetch": -1,     "list": -1,
    
    # ERGODIC (0): Coordination/​Metadata
    "label": 0,      "archive": 0,     "snooze": 0,
    "star": 0,       "mark_read": 0,   "mark_unread": 0,
    "move": 0,
    
    # PLUS (+1): Generation/​Execution
    "send": +1,      "forward": +1,    "reply": +1,
    "schedule": +1,  "draft": +1,      "compose": +1,
}

MCP Tool → Trit Mapping

ToolTritDescription
search_gmail_messages-1Search inbox (MINUS)
get_gmail_message_content-1Read message (MINUS)
get_gmail_thread_content-1Read thread (MINUS)
list_gmail_labels-1List labels (MINUS)
modify_gmail_message_labels0Change labels (ERGODIC)
batch_modify_gmail_message_labels0Bulk labels (ERGODIC)
send_gmail_message+1Send email (PLUS)
draft_gmail_message+1Create draft (PLUS)

Triadic Queue Routing

Interactions route to disjoint queue fibers:

                    ┌─────────────────────────────────────────┐
                    │           TRIADIC QUEUES                │
                    ├─────────────────────────────────────────┤
                    │                                         │
   Interaction ────▶│  route(trit) ───▶ Agent3 Fiber         │
                    │                                         │
                    │  MINUS (-1)  ────▶ [read, search, ...]  │
                    │  ERGODIC (0) ────▶ [label, archive, ...]│
                    │  PLUS (+1)   ────▶ [send, reply, ...]   │
                    │                                         │
                    └─────────────────────────────────────────┘

Invariants

  1. No duplication: Each interaction in exactly one fiber
  2. Route invariant: agent_of(i) = route(trit(i))
  3. Ordering: PLUS must be preceded by MINUS in same thread
  4. Conservation: Thread trit sum ≡ 0 (mod 3) at cycle close

Queue Depth Balance

def saturation_metrics(queues: Dict[Agent3, deque]) -> Dict:
    depths = [len(q) for q in queues.values()]
    return {
        'balance_ratio': min(depths) / max(depths),  # 1.0 = perfect
        'gf3_residue': sum(i.trit for q in queues for i in q) % 3,
    }

Saturation Detection → ANIMA State

Saturation occurs when a thread reaches stable equilibrium:

def is_saturated(thread_id: str) -> bool:
    """Thread is saturated when:
    1. No change in needs_action for N steps
    2. GF(3) cycle closure: sum(trits) ≡ 0 (mod 3)
    3. History window shows identical states
    """
    history = detector.history[thread_id][-N:]
    cycle_sum = sum(t for t in thread.gf3_cycle[-3:])
    
    return (
        all(s == history[0] for s in history) and  # Stable
        (cycle_sum % 3) == 0                        # Conserved
    )

ANIMA Detection

def detect_anima() -> Dict:
    """System at ANIMA when:
    1. All threads saturated
    2. GF(3) conserved globally
    3. Equivalence classes stable
    4. Replay invariance holds
    """
    return {
        "at_anima": all_saturated and gf3_conserved and stable_impacts,
        "condensed_fingerprint": sha256(sorted_equiv_classes),
        "persistence_bars_stable": True,
    }

Inbox Zero as ANIMA: When all threads reach saturation with GF(3) conservation, the inbox is in condensed equilibrium.

Narya Proof Integration

Proofs in src/​narya_proofs/:

1. Queue Consistency (queue_consistency.py)

def prove_queue_consistency(system: TriadicQueueSystem) -> bool:
    """Verify no duplication and route invariant."""
    return (
        system.verify_no_duplication() and
        system.verify_route_invariant()
    )

2. Replay Determinism (replay_determinism.py)

def prove_replay_determinism(schedule1, schedule2) -> bool:
    """Different schedules → identical condensed state."""
    fp1 = replay(schedule1).condensed_fingerprint
    fp2 = replay(schedule2).condensed_fingerprint
    return fp1 == fp2

3. Non-Leakage (non_leakage.py)

def prove_non_leakage(bridge: GmailMCPBridge) -> bool:
    """No interaction leaks between fibers."""
    for agent, queue in bridge.queues.items():
        for item in queue:
            if bridge._route(item.trit) != agent:
                return False
    return True

4. GF(3) Conservation (gf3_conservation.py)

def prove_gf3_conservation(bridge: GmailMCPBridge) -> bool:
    """All closed cycles satisfy sum ≡ 0 (mod 3)."""
    for cycle in bridge.cycle_tracker.closed_cycles:
        if sum(cycle.trits) % 3 != 0:
            return False
    return True

Source Files

FileDescriptionTrit
gmail_acset.pyACSet schema + GF(3) thread tracking0
anima_detector.pySaturation + equilibrium detection0
gmail_mcp_bridge.pyMCP tool wiring with guards0
triadic_queues.pyThree disjoint queue fibers0
narya_proofs/Formal verification proofs-1

Workflows

Workflow 1: Triage Inbox to ANIMA

from gmail_mcp_bridge import create_gmail_bridge
from anima_detector import AnimaDetector

# Create bridge
bridge = create_gmail_bridge("[email protected]")
detector = AnimaDetector(saturation_threshold=5)

# MINUS: Read unread messages
bridge.search_gmail_messages("is:unread")
for msg in results:
    bridge.get_gmail_message_content(msg.id, thread_id=msg.thread_id)
    detector.update_thread(msg.thread_id, trit=Trit.MINUS)

# ERGODIC: Label/​archive processed
for msg in processed:
    bridge.modify_gmail_message_labels(
        msg.id,
        add_label_ids=["Label_Processed"],
        remove_label_ids=["INBOX"],
        thread_id=msg.thread_id
    )
    detector.update_thread(msg.thread_id, trit=Trit.ERGODIC)

# Check ANIMA
anima = detector.detect_anima()
if anima["at_anima"]:
    say("Inbox at ANIMA. Condensed state achieved.")

Workflow 2: Reply with GF(3) Guard

# MINUS first: Read the thread
bridge.get_gmail_thread_content(thread_id)  # trit=-1

# PLUS: Reply (requires prior MINUS)
try:
    bridge.send_gmail_message(
        to="[email protected]",
        subject="Re: Topic",
        body="Response...",
        thread_id=thread_id,
        in_reply_to=original_message_id
    )  # trit=+1
except GF3ConservationError:
    # Must read before sending
    bridge.get_gmail_thread_content(thread_id)  # Retry after MINUS
    bridge.send_gmail_message(...)

Workflow 3: Batch Triage with Saturation

# Create balanced batch
batch = create_triadic_batch(
    payloads=["read_1", "label_1", "archive_1"],  # Will balance to 0
    thread_id="batch_thread",
    seed=1069
)

system = TriadicQueueSystem()
for interaction in batch:
    if system.enqueue(interaction):
        print(f"✓ {interaction.payload} → {interaction.agent.name}")

# Check metrics
stats = system.full_statistics()
print(f"GF(3) Residue: {stats['saturation']['gf3_residue']}")  # 0
print(f"Cycles Closed: {stats['operations']['cycles_closed']}")

Workflow 4: Sheaf Cohomology Verification

# After processing
h1 = bridge.verify_h1_obstruction()
print(f"H¹ obstructions: {h1['h1']}")
print(f"Globally consistent: {h1['globally_consistent']}")

# Obstructions = threads not at GF(3) = 0
for v in h1['violations']:
    print(f"  Thread {v['thread_id']}: residue={v['mod_3']}")

Commands

# Run Gmail ANIMA demo
python src/​gmail_acset.py

# Test triadic queues
python src/​triadic_queues.py

# Run ANIMA detector
python src/​anima_detector.py

# Run Narya proofs
python -m src.narya_proofs.runner

Integration with Other Skills

SkillTritIntegration
google-workspace0MCP tool provider
gay-mcp+1SplitMixTernary RNG
sheaf-cohomology-1H¹ obstruction verification
bisimulation-game-1State equivalence proofs
ordered-locale0Thread ordering topology

GF(3) Triadic Conservation

gmail-anima (0) ⊗ sheaf-cohomology (-1) ⊗ gay-mcp (+1) = 0 ✓
gmail-anima (0) ⊗ bisimulation-game (-1) ⊗ send (+1) = 0 ✓
read (-1) ⊗ label (0) ⊗ reply (+1) = 0 ✓

Cross-Skill Integration

Gmail-ANIMA integrates with the full workspace via WorkspaceACSet:

Morphisms from Gmail

MorphismTargetTriggerGF(3) Effect
thread_fileDriveFileAttachment detected0 (ERGODIC)
thread_eventCalendarEventMeeting scheduled+1 (PLUS)
thread_taskTaskAction item identified+1 (PLUS)

Workflow Paths

# Gmail → Task (balanced)
path = gmail_read >> task_create  # -1 + 1 = 0 ✓

# Full workflow (needs balancing)
full = gmail_read >> drive_create >> calendar_create >> task_create
balanced = balance_path(full)  # Auto-adds ERGODIC steps

MCP ↔ API Equivalence

Gmail operations can be executed via MCP tools or direct API:

# Equivalent executions
mcp_result = bridge.execute_mcp("send_gmail_message", params)
api_result = bridge.execute_api("gmail_send", params)
assert mcp_result.state == api_result.state

Source Files (Extended)

FileDescription
workspace_acset.pyUnified schema with cross-skill morphisms
mcp_api_equivalence.pyMCP↔API behavioral equivalence
path_invariance.pyWorkflow path verification
workflow_validator.pyEnd-to-end validation

ANIMA Principles Applied

ANIMA ConceptGmail Implementation
SaturationThread trit sum ≡ 0 (mod 3)
CondensationEquivalence class collapse
MaxEnt Defaultneeds_action=False initially
PersistenceOnly flip when forced
Replay InvarianceSchedule-independent fingerprint

Say Narration Integration

from gmail_mcp_bridge import NaryaLogger

logger = NaryaLogger(voice="Ava (Premium)")

# Announces: "Gmail bridge: MINUS transition"
logger.log(before, after, Trit.MINUS, impact=False)

# Announces: "Gmail bridge: PLUS transition, impact detected"
logger.log(before, after, Trit.PLUS, impact=True)

Skill Name: gmail-anima
Type: Email Management / ANIMA Framework
Trit: 0 (ERGODIC - coordinator)
GF(3): Conserved via triadic queue routing
ANIMA: Inbox Zero = Condensed Equilibrium State

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

  • general: 734 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

gmail-anima (+) + SDF.Ch10 (+) + [balancer] (+) = 0

Skill Trit: 1 (PLUS - generation)

Secondary Chapters

  • Ch6: Layering
  • Ch1: Flexibility through Abstraction

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.

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View