DHARMA धर्म

Distributed Harmonized Authority for Responsible Mesh Administration

Content moderation framework — judges actions, not identities. Host sovereignty with universal minimums.

v3.0.0

The Law That Sustains All Things

Dharma is the cosmic principle of righteous conduct — not imposed from above but arising from the nature of things. In Hindu and Buddhist philosophy, dharma is not a rule book but a living standard: it asks “does this action create harmony or harm?” DHARMA applies this principle to mesh content: it evaluates what is said, never who says it. Nine universal categories define the boundaries of harm. Beyond that, expression is free. The host may add, but never subtract.

Philosophy

धर्म (dharma) = righteous conduct. DHARMA provides content moderation that:

Judges Actions, Not Identities

Content is evaluated on what it says, not who said it. No demographic profiling, no political bias, no identity-based filtering.

Host Sovereignty

Node operators may extend DHARMA with custom patterns for their community. The 9 universal categories are the baseline — hosts add, never subtract.

Not Censorship

DHARMA blocks actionable harm — instructions for violence, exploitation of minors, doxxing coordinates. It does not filter opinions, beliefs, political speech, or controversial ideas. Yakmesh is built for free expression; DHARMA exists to keep the network safe for that expression.

9 Universal Categories

These categories cannot be disabled by any node operator — they represent the minimum standard for participation in the yakmesh network:

Category Severity Action
CHILD_EXPLOITATION CRITICAL BLOCK
HUMAN_TRAFFICKING CRITICAL BLOCK
HUMAN_SACRIFICE CRITICAL BLOCK
TERRORISM_PROMOTION HIGH BLOCK
VIOLENCE_INCITEMENT HIGH BLOCK
WEAPONS_INSTRUCTIONS HIGH FLAG
SELF_HARM_PROMOTION MEDIUM FLAG
DOXXING MEDIUM FLAG
FINANCIAL_FRAUD MEDIUM WARN

DharmaModerator

The DharmaModerator class extends EventEmitter and provides the core content checking pipeline:

import { DharmaModerator } from 'yakmesh/security/dharma-moderation';

const moderator = new DharmaModerator({
  // Optional: host-specific custom patterns
  customPatterns: [
    { id: 'spam-links', severity: 'low', keywords: ['buy now', 'click here'] }
  ],
  maxChecksPerMinute: 1000,
});

// Check content
const result = await moderator.checkContent(
  'Some user message here...',
  { roomId: 'general', userId: 'abc123' }
);

// Result:
// {
//   action: 'ALLOW',        // BLOCK | FLAG | WARN | LOG | ALLOW
//   violations: [],          // matched categories (if any)
//   severity: null,          // 'critical' | 'high' | 'medium' | 'low' | null
//   normalized: '...',       // content after obfuscation stripping
// }

Anti-Obfuscation

Before pattern matching, DHARMA normalizes content to defeat common obfuscation techniques:

Obfuscation Normalized
0 (zero) o
@ a
$ s
1 (one) i or l
Whitespace / special chars between letters → collapsed

Action Levels

BLOCK
Message is silently dropped. Sender receives generic error. Used for CRITICAL and HIGH severity.
FLAG
Message is delivered but flagged for host review. Used for HIGH and MEDIUM severity.
WARN
Sender receives a warning. Message still delivered. Used for MEDIUM severity.
LOG
Event logged for telemetry only. No user-visible action. Used for LOW severity.
ALLOW
Content passes all checks. Normal delivery.

Host Sovereignty

Node operators can extend DHARMA with custom patterns for their community. Custom patterns are added via the customPatterns config array:

const moderator = new DharmaModerator({
  customPatterns: [
    {
      id: 'no-crypto-shilling',
      severity: 'low',
      description: 'Block cryptocurrency pump-and-dump messages',
      keywords: ['100x guaranteed', 'moon shot', 'buy before midnight'],
      action: 'WARN',
    },
    {
      id: 'nsfw-filter',
      severity: 'medium',
      description: 'NSFW content filter for family-friendly server',
      regex: [/explicit_pattern/i],
      action: 'FLAG',
    },
  ],
});

// Custom patterns are checked AFTER the 9 universal categories.
// Hosts can add rules but cannot disable universal protections.

Events

DharmaModerator extends EventEmitter and fires events on violations:

moderator.on('violation', (result) => {
  console.log(`${result.action}: ${result.violations[0].category}`);
  // 'BLOCK: CHILD_EXPLOITATION'
});

moderator.on('block', (result) => {
  // Only fires for BLOCK actions
  reportToAdminDashboard(result);
});

Version History

Version Changes
v3.0.0 Full DHARMA module: 9 prohibited categories, DharmaModerator class, anti-obfuscation normalization, host sovereignty, event system.
v2.9.0 Initial content check pipeline design.