Skip to content

V0.1.5 - #145

Merged
GianIac merged 20 commits into
mainfrom
v0.1.5
Sep 19, 2026
Merged

V0.1.5#145
GianIac merged 20 commits into
mainfrom
v0.1.5

Conversation

@GianIac

@GianIac GianIac commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

This pull request implements v0.1.5, introducing dynamic peer candidate discovery to Numax while maintaining backward compatibility with static --peer deployments.

Prior to v0.1.5, clustering required knowing and configuring all remote peer addresses statically ($O(N^2)$ operational complexity). This release introduces the PeerDiscovery abstraction, candidate coordination in nx-core, discovery modes (mDNS, Bootstrap Gossip, DNS-SRV, and File Watch), and dynamic endpoint resolution without breaking authentication or transport boundaries.

Architectural Changes & Key Additions:

1. nx-core: Discovery Abstraction & Coordination (crates/nx-core/src/discovery/)

  • PeerDiscovery Contract: Defines discover(), watch(), and announce() primitives with atomic snapshot-watch consistency.
  • CandidateCoordinator & CandidateRegistry:
    • Aggregates candidates from multiple providers with deterministic ordering and deduplication.
    • Manages candidate source leases, contribution tracking, and clean removal when providers expire or disconnect.
    • Enforces DEFAULT_DISCOVERY_EVENT_CAPACITY and MAX_DISCOVERY_EVENT_CAPACITY limits across broadcast channels.
  • Provider Implementations:
    • StaticDiscovery: Preserves backward compatibility with CLI/TOML --peer configurations.
    • MdnsDiscovery: Zero-configuration peer discovery for local networks over UDP multicast 5353.
    • BootstrapGossipDiscovery: Seed-based candidate exchange for bootstrap discovery.
    • DnsSrvDiscovery: Periodic DNS SRV record resolution with TTL-aware polling.
    • FileWatchDiscovery: File-system-based dynamic candidate updates for container orchestrators.

2. nx-net: Bootstrap Protocol & Configuration Validation (crates/nx-net/)

  • Bootstrap Protocol: Implements BootstrapClient, BootstrapServer, and WireMessage::bootstrap_hello for exchanging peer candidates during bootstrap.
  • Configuration Hardening:
    • Added InvalidConfig variant to NetError for descriptive configuration errors.
    • Introduced NodeConfig::validate() and Node::try_new() to validate peer limits, timeouts, and channel capacities before resource allocation.
    • Enforced strict canonicalization and validation for advertised listening endpoints.
  • Cross-Platform Test Hardening: Adjusted TLS bootstrap rejection assertions to avoid OS-specific socket shutdown discrepancies on Windows.

3. nx-cli: Configuration & CLI Integration (crates/nx-cli/)

  • Extended DiscoveryMode (static, bootstrap, mdns, dns-srv, file) in TOML and CLI flags:
    • --discovery-mode <MODE>
    • --advertised-endpoint <IP:PORT>
    • --cluster-id <ID>
    • --bootstrap-seed <IP:PORT>
  • Precedence chain preserved: CLI flags > Environment variables (NX_*) > TOML config > Defaults.

4. Examples & Verification (examples/discovery_lan/)

  • Added real three-daemon mDNS discovery demonstration on LAN (examples/discovery_lan/).
  • Verifies zero-configuration mDNS discovery, GCounter CRDT synchronization, clean disconnect detection, durable identity restart, and missed-operation recovery without static --peer.

5. Documentation (docs/nx-site/)

  • Added comprehensive design documentation: Peer Discovery Contract.
  • Documented advertised endpoint resolution rules (--listen vs --advertised-endpoint, wildcard binds, and dynamic port allocation).
  • Updated configuration references, CLI documentation, and roadmap progression.

Invariants & Safety Guarantees Preserved:

  • Separation of Discovery and Authorization: Discovering an endpoint candidate does not grant authorization. TLS, mTLS, node identity verification, and handshake policies remain strictly enforced by nx-net.
  • Deduplication & Convergence: Materialized CRDT state persistence, op-log replay, and deduplication logic in sync_manager remain intact.
  • Resource Bounds: Candidate registries and event channels are bounded by max_candidates and MAX_DISCOVERY_EVENT_CAPACITY (4096) to prevent unbounded memory growth.
  • Graceful Lifecycle: Long-running discovery tasks use AbortOnDropTask and explicit shutdown triggers for deterministic teardown.

- Introduced `demo.mjs` for initializing and managing a discovery LAN instance.
- Implemented `demo.test.mjs` for testing the demo script with various scenarios.
- Added a Rust library (`lib.rs`) for handling CRDT state observation and increment operations.
- Updated dependencies in multiple example projects to use `nx-sdk` version 0.1.5.
- Added `InvalidConfig` variant to `NetError` for better error reporting on invalid node configurations.
- Implemented `validate` method in `NodeConfig` to enforce limits on `max_peers`, `event_channel_capacity`, and `socket_timeout` before resource allocation.
- Introduced `try_new` method in `Node` to create nodes with immediate validation, returning errors for invalid configurations.
- Updated various methods in `Node` to validate configurations before operations, ensuring robustness against misconfigurations.
- Enhanced documentation to clarify the validation process and error handling in the context of node creation and management.
- Improved tests to cover new validation logic and ensure that invalid configurations are handled gracefully without panics.
…c:Introduced with`MAX_DISCOVERY_EVENT_CAPACITY` constant to limit event capacity to 4096, with validation in dynamic provider constructors, enhanced `CandidateRegistry` to better handle candidate contributions and ensuring proper expiration and renewal logic.
…y `--listen` vs `--advertised-endpoint` usage
@GianIac
GianIac merged commit 471a228 into main Sep 19, 2026
24 checks passed
@GianIac
GianIac deleted the v0.1.5 branch September 19, 2026 19:59
@GianIac
GianIac restored the v0.1.5 branch September 19, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant