Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:23blocks OS Ai maestro Host Identity

From Leeroopedia
Knowledge Sources
Domains Mesh_Networking, Identity
Last Updated 2026-10-26 10:00 GMT

Overview

A host identity pattern where each machine is identified by its canonical hostname (lowercase, no .local suffix), with self-detection centralized in one function that checks hostname, IPs, and legacy values.

Description

Host identity in the mesh is based on the machine's hostname, normalized to lowercase with the `.local` suffix stripped (macOS Bonjour/mDNS). The `getSelfHostId` function returns this canonical ID. The `isSelf` function is the only place where self-detection happens — it checks the hostname, all local IPs, and the legacy 'local' value.

Centralizing self-detection prevents the class of bugs where one module thinks a host is self and another doesn't (e.g., when hostname changes due to dock/WiFi switching). `getPublicUrl` detects the host's public URL, preferring Tailscale IPs (100.x.x.x) over LAN, never returning localhost.

Usage

Use this principle when designing a peer-to-peer mesh where:

  • Host identity must be consistent across all modules
  • A machine's identity changes with network configuration (dock, WiFi, Tailscale)
  • Self-detection must handle multiple signals (hostname, IPs, legacy values)

Theoretical Basis

The identity is canonical hostname with centralized self-detection:

getSelfHostId() = os.hostname().toLowerCase().replace(/\.local$/, '')

isSelf(hostId) =
  hostId == getSelfHostId()
  || hostId == 'local'          // legacy
  || hostId in localIPs()       // IP match
  || hostId in hostAliases()    // configured aliases

The principle is single source of self-detection: every module that needs to know "is this me?" calls `isSelf`, and `isSelf` alone handles the multi-signal matching. This eliminates the divergence class.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment