STUPA स्तूप

Signal Transmission Unit for Peer Awareness

Priority-based broadcast messaging across the Yakmesh network.

v2.5.0

The Sacred Tower

In Himalayan Buddhist tradition, a stupa is a sacred structure that rises above the landscape, radiating spiritual presence to all who see it. Pilgrims from every direction are drawn to its signal.

The STUPA protocol embodies this principle—when a node broadcasts a critical message, it rises like a sacred tower above the mesh, ensuring all peers receive the signal according to its urgency.

Overview

STUPA (Signal Transmission Unit for Peer Awareness) provides priority-based broadcast messaging for the Yakmesh network. Unlike MANTRA's epidemic gossip, STUPA messages are explicitly broadcast to all connected peers with priority levels that determine propagation urgency.

Protocol Family

Protocol Himalayan Name Purpose
Gossip MANTRA Epidemic message propagation
Broadcast STUPA Priority-based broadcasting
Oracle LAMA Distributed consensus
Time MANI Temporal synchronization
Trust KARMA Reputation management
Mesh MANDALA Network topology

Priority Levels

STUPA messages carry priority levels inspired by the tiers of a stupa's ascending structure. Higher priority messages propagate faster and with greater urgency:

5

CRITICAL

Security breaches, network-wide emergencies. Immediate propagation.

4

FLASH

Urgent operational messages requiring rapid response.

3

IMMEDIATE

High-priority messages with expedited handling.

2

PRIORITY

Important messages with elevated processing.

1

ROUTINE

Standard broadcasts processed normally.

Core Components

StupaMessage

The fundamental message unit for broadcasts:

import { StupaMessage, STUPA_PRIORITY } from 'yakmesh/mesh/beacon-broadcast';

// Create a broadcast message
const message = new StupaMessage({
  type: 'NETWORK_ALERT',
  payload: { alert: 'Node cluster offline', region: 'asia-1' },
  priority: STUPA_PRIORITY.FLASH,
  ttl: 300, // 5 minutes
  origin: nodeId
});

// Message properties
console.log(message.id);        // Unique message ID
console.log(message.priority);  // Priority level
console.log(message.hops);      // Propagation count
console.log(message.isExpired); // TTL check

StupaBroadcast

The broadcast controller managing message propagation:

import { StupaBroadcast, STUPA_CONFIG } from 'yakmesh/mesh/beacon-broadcast';

// Initialize the broadcast system
const stupa = new StupaBroadcast(node, {
  ...STUPA_CONFIG,
  maxHops: 10,
  deduplicationWindow: 60000 // 1 minute
});

// Broadcast a message
await stupa.broadcast({
  type: 'CONSENSUS_REACHED',
  payload: { decision: 'upgrade-v2', votes: 42 },
  priority: STUPA_PRIORITY.IMMEDIATE
});

// Listen for broadcasts
stupa.on('message', (message) => {
  console.log(`Received ${message.type} from ${message.origin}`);
  console.log(`Priority: ${stupa.getPriorityName(message.priority)}`);
});

Event System

STUPA emits events for broadcast lifecycle management:

Event Payload Description
message StupaMessage New broadcast received from the network
broadcast StupaMessage Message successfully broadcast to peers
forward StupaMessage Message forwarded to next-hop peers
expired StupaMessage Message TTL exceeded, dropped
duplicate messageId Duplicate message detected and filtered

Configuration

export const STUPA_CONFIG = {
  // Message propagation
  maxHops: 10,              // Maximum hop count before drop
  defaultTTL: 3600,         // Default message TTL (1 hour)
  
  // Deduplication
  deduplicationWindow: 60000, // Duplicate detection window (ms)
  maxSeenMessages: 10000,     // Message ID cache size
  
  // Priority handling
  priorityQueues: true,       // Enable priority-based queuing
  criticalBypass: true,       // CRITICAL skips normal queue
  
  // Rate limiting
  maxBroadcastsPerMinute: 60, // Outbound rate limit
  burstAllowance: 10          // Burst capacity
};

Message Flow

Originate

Node creates StupaMessage with priority

Broadcast

StupaBroadcast sends to all peers

Forward

Peers relay based on TTL and hops

Deliver

All nodes receive the broadcast

Security Considerations

Integration with Other Protocols

MANTRA

STUPA for urgent broadcasts, MANTRA for eventual consistency

LAMA (Oracle)

Consensus results broadcast via STUPA IMMEDIATE priority

KARMA

Trust scores determine broadcast acceptance thresholds

MANDALA

Mesh topology optimizes broadcast routing paths

YPC-27

Quantum-hard 27-trit checksums for message integrity (v2.7.1+)

Backward Compatibility

For existing codebases using the original "Beacon" naming, legacy exports are maintained:

// Legacy imports still work
import { BeaconBroadcast, BeaconMessage, BEACON_CONFIG } from 'yakmesh/mesh/beacon-broadcast';

// These map to the new STUPA names
// BeaconBroadcast → StupaBroadcast
// BeaconMessage → StupaMessage
// BEACON_CONFIG → STUPA_CONFIG