Commit Graph
7 Commits
Author SHA1 Message Date
faumaray 1474a69ab1 feat(service): immutable snapshots, owning ServiceHandle, DAG lifecycle, and ServicePlugin split 2026-11-26 16:03:31 +03:00
faumaray 053ee5b296 update
CI / GCC 16 / C++26 / sanitizers (push) Failing after 4s
CI / GCC 16 / C++26 / werror (push) Failing after 3s
CI / GCC 16 / C++26 / default (push) Failing after 1m48s
Signed-off-by: faumaray <faumaray@gmail.com>
2026-07-25 23:42:52 +03:00
faumarayandClaude Fable 5 ee4486e1d2 Plugin: discovery, unload, config entry, multi-observer reloads, state API
Host-side additions for applications embedding a plugin system:

- PluginManager::load_directory(dir) loads every shared-library file in
  a directory (filename order) with per-file expected results.
- PluginManager::unload(name) drops the registry entry; the instance
  dies with its last pinned handle (RCU semantics, as on reload).
- Optional C entry void_plugin_configure(inst, config): fed from
  PluginManagerOptions::config_provider after create and after each
  reload swap, before on_load().
- on_reloaded() is now multi-observer: returns a ReloadCallbackId,
  remove_on_reloaded() unregisters. Manual reload() now notifies
  observers too (previously only watched reloads did, contradicting
  the documented contract). PluginServiceBinding deregisters its
  callback on destruction (was a dangling-callback hazard).
- PluginManager::serialize_state/deserialize_state expose the plugin's
  v2 state exports so an embedder can carry plugin state through its
  own hot reload.
- ServiceRegistry::remove<I>() withdraws a provided service (child
  removal re-exposes a parent's entry).
- EventBus::subscribe_scoped<E>() returns a move-only RAII
  Subscription that unsubscribes on destruction.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018yj92cCihyaYtf4gKCT3nv
2026-07-11 23:39:10 +03:00
faumarayandClaude Opus 4.8 adc0de310e Service: allow registering non-polymorphic service types
ServiceRegistry::provide<I> cross-cast to IService via dynamic_cast, which
fails to compile when I is a plain (non-polymorphic) value type. Guard the
cross-cast with std::is_polymorphic_v<I>; non-polymorphic services are
stored and resolvable but carry no lifecycle aspect. Test added.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 16:59:02 +03:00
faumarayandClaude Opus 4.8 80293ee56f Add async/resilience/reflection primitives + FSM v2 rewrite
A round of new universal capabilities (all generic — templated/reflection
based, no app coupling), verified by the test suite (1103 passing):

Data reflection:
- Reflect.hpp now (de)serializes chrono::duration, chrono::time_point,
  std::variant (tagged), std::array, and non-string-keyed std::map;
  Meta.hpp gains is_time_point_v et al.

Async:
- EventBus gains Mode::Async (worker-thread dispatch + flush()).
- ThreadPool gains a bounded queue, try_submit(), and rejection stats.

New modules / containers:
- Resilience: TokenBucket, KeyedRateLimiter<Key>, CircuitBreaker,
  ResourceMonitor.
- Containers: BufferPool<T> (size-class buffer reuse) and Cache<K,V>
  (per-entry TTL, LRU/LFU/FIFO eviction, hit/miss stats).
- System: process/CPU/memory metrics (Metrics.hpp) and a streaming
  Process API.

Plus FSM v2 (typed Success/Failure, sub-machines, parallel regions,
history states, deferred events), Configuration/Logging reflection
helpers, and the accompanying test suites.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 15:45:16 +03:00
faumarayandClaude Fable 5 7b6cd7341a Plugins provide services: hot-reload + state-saving via the registry
Re-expresses the old FSM-plugin hot-plug through the service layer,
reusing the unchanged Plugin module (PluginManager, v2 serialize/
deserialize ABI, FileWatcher, atomic-rename install).

Service/PluginService.hpp: PluginServiceBinding<I> resolves a plugin's
exported service (extern "C" void_plugin_service(instance) -> IService*)
via PluginManager::raw_symbol and registers it under interface I. The
registry entry pins the plugin instance (and its mapped .so) so in-flight
callers never see a freed object. enable_hot_reload() re-binds on each
reload; the FSMs resolve I through their context, so a running FSM picks
up the new implementation on its next service<I>() call with no code
patched. I must derive IService (single inheritance) so the host recovers
it from IService* by static_cast — no dynamic_cast across RTLD_LOCAL.

Tests: ServicePluginV1/V2 (the plugin object is the service: IPlugin +
ICalc : IService; v2 migrates v1 state via Json::MigrationChain).
FsmServiceHotReload.cpp: an Orchestrator-launched FSM accumulates through
the plugin service while a reloader thread flips v1<->v2 under load —
state survives every migration, the FSM runs to completion, no crash; and
a deterministic reload test proving the implementation swaps (version
1->2) with the running total migrated.

Docs: CLAUDE.md/README updated for the new Fsm, Service, and Orchestrator
(StateMachine row removed). 965 tests green, ASan+UBSan clean, stable
across runs, -Werror clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-14 00:47:47 +03:00
faumarayandClaude Fable 5 cfeaf93a53 Add Service registry and rewrite Fsm as an inheritance/coroutine workflow
Service module (Void::Service):
- IService base (service_name + on_start/on_stop lifecycle).
- ServiceRegistry: type-keyed container — provide<I>(impl), get<I>()
  (nullptr if absent), require<I>() (throws), has<I>(), start_all/
  stop_all. Consumers depend only on the interface I and resolve at
  runtime (dependency inversion); a concrete that derives IService is
  recovered for lifecycle via dynamic_cast even when registered under a
  plain interface. shared_mutex; reads are the hot path.

New Void::Fsm — a single inheritance + coroutine workflow FSM replacing
the deleted statechart/compile-time FSMs:
- Derive Machine<ResultT>; declare states as nested structs deriving
  State; each implements Coro::Task<Step> run() returning next<S>() /
  succeed(...) / fail(...).
- Async by default: a non-template Detail::ExecutionContext owns one
  ManualExecutor + worker thread + a lock-free MPSC event queue + a typed
  event mailbox; a single consumer touches all mutable state so state
  code is lock-free/single-threaded. Embedder mode (own_worker=false)
  drives via pump() for deterministic tests.
- Events: co_await await_event<E>() consumes the oldest queued E (typed
  mailbox), suspending until one arrives; post<E>(e) is lock-free from
  any thread.
- Nesting: co_await run_child<Sub>(args...) runs a child on the same
  executor (shared events/services) and yields its Outcome.
- Dynamic: add<S>() / add_if<S>(cond) register states; next<unregistered>
  fails; has_state<S>() lets states branch.
- Services: set_services(registry); state.service<I>() resolves through
  the injected context.
- Observation: current_state() is a lock-free atomic-index read of an
  immutable name table (P2996 identifier_of, fallback to indexed names).
- Persistence: serialize() captures {state name, on_serialize data};
  restore() on an un-started machine resumes at the named state.

26 new tests (Service registry; FSM basic/success/fail, events incl.
cross-thread worker + order, nesting incl. failure propagation,
serialize/restore, dynamic registration, service resolution, and a
6-producer x 5k concurrent-post stress + lock-free current_state reader
check). 960 green, ASan+UBSan clean, stable across 10 runs, -Werror clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-14 00:39:05 +03:00