4.1 KiB
4.1 KiB
S-DISCOVERY-01..04 — Discovery Subsystem (Catalog, Leases, Watches, Selectors, Optional RPC Adapter)
Scope
Implement the P1–P3 native Void::Discovery subsystem per docs/roadmap/subsystems/Discovery.md and docs/roadmap/DEPENDENCIES.md, plus the optional Void::DiscoveryRpc endpoint adapter living strictly above RPC and Discovery:
S-DISCOVERY-01— Boundary, Error Domain, and Immutable Value Contracts:- Module
src/Discovery/module.cmake(INTERNAL_DEPS Core Functional Time Async) with zero network, storage, or consensus dependencies. - Error domain
kDiscoveryErrorDomain = 30withDiscoveryErrorCodecovering validation, conflict, cap exhaustion, expiry, stale/unavailable freshness, cancellation, and self-join diagnosis. - Strict endpoint/attribute validation before publication (valid scheme/host/port,
weight > 0,max_attributes_per_record = 16,max_metadata_bytes_per_record = 4096,max_services = 1024,max_endpoints_per_service = 256,max_total_records = 10000).
- Module
S-DISCOVERY-02— Pure Catalog, Atomic Static Snapshots, and Local RAII Registrations:- Pure
Catalogconstruction creating zero hidden threads. - Atomic candidate
replace_static()rejecting invalid/conflicting candidates while preserving the active revision; explicitprovider_generationbump resets revision domain and emitsResyncRequired. - Local move-only RAII
Registrationhandles with explicitLeasePolicy(default 30s TTL / 10s renew interval via injectedMonotonicClock; zero TTL rejected asInvalidArgument; unleased explicit mode valid until release; static entries never expire). - Duplicate
(service, instance)returnsConflictwithout stealing existing handles. - Deterministic
resolve()sorted byinstance, filtering logically expired records before cleanup runs, respectingResolvePolicy::allow_staleandFreshness.
- Pure
S-DISCOVERY-03— Bounded Watches, Resync, Client Selectors, and Managed Renewal:- Bounded
watch()(max_watches = 1024,max_events_per_watch = 64, shared16 MiBevent budget) emittingInitialSnapshot, serialized per-watchDelta, and explicitResyncRequired+ full latestSnapshoton overflow or provider-generation reset. - Callbacks run outside catalog and watch locks;
cancel()stops new admission (including self-cancel inside a callback);join()drains admitted callbacks and diagnoses synchronous self-join (SelfJoin) instead of deadlocking. Catalog::shutdown_and_join()removes local entries, cancels watches, and joins admitted callbacks; destructor only requests stop.WeightedRoundRobinSelector, stable HRWAffinitySelector, and deterministicManagedLeaseRenewer.
- Bounded
S-DISCOVERY-04— Optional RPC Integration (DiscoveryRpc):- Separate module
src/DiscoveryRpc/module.cmake(INTERNAL_DEPS Discovery RPC) soRPCremains completely independent ofDiscovery. EndpointResolverClientresolves endpoints fromDiscovery::Catalog, selects via client selector, preserves configuredexpected_tls_name/ identity across IP/address refreshes (rejecting TLS scheme/identity downgrade), and executes unary calls viaVoid::RPC::Client.
- Separate module
File Ownership
include/Void/Discovery/{Types,Catalog}.hppsrc/Discovery/{module.cmake,Catalog.cpp}include/Void/DiscoveryRpc/EndpointAdapter.hppsrc/DiscoveryRpc/{module.cmake,EndpointAdapter.cpp}tests/standalone/Discovery/Catalog.cpptests/standalone/DiscoveryRpc/EndpointAdapter.cpptests/package/DiscoveryOnly/{CMakeLists.txt,main.cpp}tests/package/InstalledComponents.cmake
Acceptance & Verification
- Standalone
Discovery;Testing(-DVOID_WARNINGS_AS_ERRORS=ON) +DiscoveryOnlyconsumer with_no_external_deps. DiscoveryRpcidentity-preserving refresh + RPC round-trip tests;RpcOnlyremains Discovery-free.- Deterministic fake-clock lease expiry/renewal, atomic bad/good config replacement, duplicate registration conflict, watch overflow ->
ResyncRequired, self-cancel/self-join, and selector determinism. - Full
RelWithDebInfo,DebugASan+UBSan, andDebugTSanwith 0 leaks, 0 UB, 0 races.