hsnlabs
Swarm Self-Healing
SSH-SPEC-0001 · v0.1.0 · Open MIT Runtime & Specification

Swarm Self-Healing Deterministic homeostasis & sub-5s hot failover for autonomous AI swarms.

A pure-Python resilience, thermal governance, and resource protection runtime for distributed agentic fleets, providing sub-5-second hot standby failover, discrete thermal hysteresis, 3-tier proxy affinity verification, and sliding-window circuit breakers over hexagonal ports.

Swarm Self-Healing Thermal Homeostasis and Failover Chamber

Four Operational Failure Modes Eliminated

Long-horizon autonomous swarms operating over hostile external surfaces fail when worker mortality, rate-limit heat, proxy drift, or provisioning storms go unchecked. Swarm Self-Healing enforces four deterministic guarantees:

01

Cold-Boot Failover Latency

Eliminates multi-minute mission stalls when an active worker drops or gets banned by maintaining a warm pool of STANDBY_READY Scouts and promoting replacements in under 5 seconds.

02

Terminal Rate-Limit Bans

Prevents irreversible identity burn via a bounded thermal score in [0.0, 1.0] with discrete friction deltas and hysteresis that preemptively moves stressed workers to COOLING_DOWN at 0.78.

03

Proxy Drift & Identity Correlation

Blocks cross-account contamination and residential DHCP drift through 3-tier network affinity validation (Endpoint Match, Subnet/ASN Match, or Hard Reject) before any external dispatch.

04

Infinite Provisioning Storms

Halts runaway SIM/eSIM and proxy financial drain during systemic target outages via a sliding-window ResourceCircuitBreaker that locks incubator expenditure until explicit operator review.

The Four Architectural Pillars

Formalized in SSH-SPEC-0001 and implemented in zero-I/O pure Python 3.11+ with Pydantic v2 and hexagonal typing.Protocol ports.

Pillar I · Homeostasis Controller

Sub-5s Hot Standby Promotion

BANNED / COOL Demote Active STANDBY_READY → ACTIVE (<5s) 1. HOT PROMOTE 2. ASYNC REFILL

Reconciles fleet invariants on every heartbeat tick: demotes overheated or banned workers, immediately promotes the coolest STANDBY_READY Scout into ACTIVE duty, and triggers asynchronous background pool replenishment.

Pillar II · Thermal Governance

HeatPolicy & Preventive Hysteresis

≤ 0.35 STANDBY OK ≥ 0.78 COOLDOWN 1.00 BANNED

Tracks discrete operational friction (normal_turn +0.06, TurnTimeout +0.18, CaptchaOrBlock +0.35, BanDetected → 1.0) and passive decay (-0.08/min), enforcing a wide 0.35..0.78 hysteresis deadband against state thrashing.

Pillar III · Network Isolation

3-Tier NetworkAffinityGuard

1:1 BINDING 1 Scout = 1 Proxy ASN + /24 Subnet 3-TIER GUARD Exact / DHCP OK Mismatch → Halt

Enforces strict 1:1 identity-to-proxy binding while gracefully tolerating legitimate ISP DHCP renewals within the same ASN and /24 IPv4 (or /48 IPv6) prefix, raising ProxyAffinityViolationError on anomalous jumps.

Pillar IV · Financial Protection

ResourceCircuitBreaker

CLOSED < 5 fails / 600s OPEN (LOCKED) Manual Unlock

Tracks ban and provisioning failures across a rolling 600-second window. Reaching 5 failures trips the breaker to OPEN, blocking all automated provisioning until explicit operator inspection and unlock().

Architectural Guarantees & Operational Proofs

Designed as a standalone, zero-I/O core that plugs into any orchestrator, ledger, or cloud provisioner via two structural protocols.

01 • Hexagonal Purity

Zero coupled database drivers or HTTP clients. State persistence and infrastructure lifecycle are injected strictly via SwarmLedgerPort and ScoutProvisionerPort.

02 • Priority-Ordered Recovery

Hot standby promotion always executes before new cold provisioning, ensuring active mission continuity even if the external incubator is degraded or circuit-broken.

03 • Bounded Thermal Math

Piecewise-linear clamping guarantees heat_score ∈ [0.0, 1.0] under arbitrary event bursts, while dual thresholds (0.35 vs 0.78) prevent oscillation.

04 • Zero-Interruption DHCP

Distinguishes benign ISP IP rotation within the same /24 subnet and ASN from true proxy hijacking, updating records in-place without dropping active sessions.

05 • Verified Sub-5s SLA

Validated by an isolated pytest suite proving sub-5-second failover promotion, hysteresis saturation, 3-tier subnet checks, and circuit-breaker storm suppression.

Explore the Specification & Reference Runtime

The complete SSH-SPEC-0001 specification, hexagonal port definitions, and pure-Python reference package with full pytest verification are available under the MIT License.

GitHub · hsnlabs-ai/swarm-self-healing Read SSH-SPEC-0001 Back to Products