Framework orchestration with builder pattern.
Source: src/core/framework.zig
Availability: Always enabled
pub const Framework| const | source |
Framework orchestration handle.
The Framework struct is the central coordinator for the ABI framework. It manages the lifecycle of all enabled feature modules, provides access to their contexts, and maintains the frameworkâs runtime state.
The Framework itself is not thread-safe. If you need to access the framework from multiple threads, you should use external synchronization or ensure each thread has its own Framework instance.
The Framework allocates memory for feature contexts during initialization. All
allocated memory is released when deinit() is called. The caller must ensure
the provided allocator remains valid for the lifetime of the Framework.
var fw = try Framework.init(allocator, Config.defaults());
defer fw.deinit();
// Check state
if (fw.isRunning()) {
// Access features
if (fw.gpu) |gpu_ctx| {
// Use GPU...
}
}
pub const State| const | source |
Framework lifecycle states.
pub const Error| const | source |
Composable framework error set.
See core/errors.zig for the full hierarchy.
pub fn init(allocator: std.mem.Allocator, cfg: Config) Error!Framework| fn | source |
Initialize the framework with the given configuration.
This is the primary initialization method for the Framework. It validates the
configuration, initializes all enabled feature modules, and transitions the
framework to the running state.
allocator: Memory allocator for framework resources. Must remain valid for
the lifetime of the Framework.cfg: Configuration specifying which features to enable and their settings.A fully initialized Framework instance in the running state.
ConfigError.FeatureDisabled: A feature is enabled in config but disabled at compile timeerror.OutOfMemory: Memory allocation failederror.FeatureInitFailed: A feature module failed to initializevar fw = try Framework.init(allocator, .{
.gpu = .{ .backend = .vulkan },
.database = .{ .path = "./data" },
});
defer fw.deinit();
pub fn initWithIo(allocator: std.mem.Allocator, cfg: Config, io: std.Io) Error!Framework| fn | source |
Initialize the framework with the given configuration and an I/O backend.
This method is used by the builder when withIo is supplied.
pub fn initDefault(allocator: std.mem.Allocator) Error!Framework| fn | source |
Create a framework with default configuration.
This is a convenience method that creates a framework with all compile-time enabled features also enabled at runtime with their default settings.
allocator: Memory allocator for framework resourcesA Framework instance with default configuration.
var fw = try Framework.initDefault(allocator);
defer fw.deinit();
pub fn initMinimal(allocator: std.mem.Allocator) Error!Framework| fn | source |
Create a framework with minimal configuration (no features enabled).
This creates a framework with no optional features enabled. Only the runtime context is initialized. Useful for testing or when you want to explicitly enable specific features.
allocator: Memory allocator for framework resourcesA Framework instance with minimal configuration.
var fw = try Framework.initMinimal(allocator);
defer fw.deinit();
// Only runtime is available, no features enabled
try std.testing.expect(fw.gpu == null);
try std.testing.expect(fw.ai == null);
pub fn builder(allocator: std.mem.Allocator) FrameworkBuilder| fn | source |
Start building a framework configuration.
Returns a FrameworkBuilder that provides a fluent API for configuring and initializing the framework.
allocator: Memory allocator for framework resourcesA FrameworkBuilder instance for configuring the framework.
var fw = try Framework.builder(allocator)
.withGpuDefaults()
.withAi(.{ .llm = .{} })
.build();
defer fw.deinit();
pub fn deinit(self: *Framework) void| fn | source |
Shutdown and cleanup the framework.
This method transitions the framework to the stopping state, deinitializes
all feature contexts in reverse order of initialization, cleans up the registry,
and finally transitions to stopped.
After calling deinit(), the framework instance should not be used. Any
pointers to feature contexts become invalid.
This method is idempotent - calling it multiple times is safe.
var fw = try Framework.initDefault(allocator);
// ... use framework ...
fw.deinit(); // Clean up all resources
pub fn shutdownWithTimeout(self: *Framework, timeout_ms: u64) bool| fn | source |
Shutdown with timeout. Currently synchronous (timeout reserved for future async cleanup). Returns true if clean shutdown completed.
pub fn isRunning(self: *const Framework) bool| fn | source |
Check if the framework is running.
pub fn isEnabled(self: *const Framework, feature: Feature) bool| fn | source |
Check if a feature is enabled.
pub fn getState(self: *const Framework) State| fn | source |
Get the current framework state.
pub fn getGpu(self: *Framework) Error!*gpu_mod.Context| fn | source |
Get GPU context (returns error if not enabled).
pub fn getAi(self: *Framework) Error!*ai_mod.Context| fn | source |
Get AI context (returns error if not enabled).
pub fn getDatabase(self: *Framework) Error!*database_mod.Context| fn | source |
Get database context (returns error if not enabled).
pub fn getNetwork(self: *Framework) Error!*network_mod.Context| fn | source |
Get network context (returns error if not enabled).
pub fn getObservability(self: *Framework) Error!*observability_mod.Context| fn | source |
Get observability context (returns error if not enabled).
pub fn getWeb(self: *Framework) Error!*web_mod.Context| fn | source |
Get web context (returns error if not enabled).
pub fn getCloud(self: *Framework) Error!*cloud_mod.Context| fn | source |
Get cloud context (returns error if not enabled).
pub fn getAnalytics(self: *Framework) Error!*analytics_mod.Context| fn | source |
Get analytics context (returns error if not enabled).
pub fn getAuth(self: *Framework) Error!*auth_mod.Context| fn | source |
Get auth context (returns error if not enabled).
pub fn getMessaging(self: *Framework) Error!*messaging_mod.Context| fn | source |
Get messaging context (returns error if not enabled).
pub fn getCache(self: *Framework) Error!*cache_mod.Context| fn | source |
Get cache context (returns error if not enabled).
pub fn getStorage(self: *Framework) Error!*storage_mod.Context| fn | source |
Get storage context (returns error if not enabled).
pub fn getSearch(self: *Framework) Error!*search_mod.Context| fn | source |
Get search context (returns error if not enabled).
pub fn getGateway(self: *Framework) Error!*gateway_mod.Context| fn | source |
Get gateway context (returns error if not enabled).
pub fn getPages(self: *Framework) Error!*pages_mod.Context| fn | source |
Get pages context (returns error if not enabled).
pub fn getBenchmarks(self: *Framework) Error!*benchmarks_mod.Context| fn | source |
Get benchmarks context (returns error if not enabled).
pub fn getMobile(self: *Framework) Error!*mobile_mod.Context| fn | source |
Get mobile context (returns error if not enabled).
pub fn getAiCore(self: *Framework) Error!*ai_core_mod.Context| fn | source |
Get AI core context (agents, tools, prompts).
pub fn getAiInference(self: *Framework) Error!*ai_inference_mod.Context| fn | source |
Get AI inference context (LLM, embeddings, vision).
pub fn getAiTraining(self: *Framework) Error!*ai_training_mod.Context| fn | source |
Get AI training context (pipelines, federated).
pub fn getAiReasoning(self: *Framework) Error!*ai_reasoning_mod.Context| fn | source |
Get AI reasoning context (Abbey, RAG, eval).
pub fn getRuntime(self: *Framework) *runtime_mod.Context| fn | source |
Get runtime context (always available).
pub fn getRegistry(self: *Framework) *Registry| fn | source |
Get the feature registry for runtime feature management.
pub fn isFeatureRegistered(self: *const Framework, feature: Feature) bool| fn | source |
Check if a feature is registered in the registry.
pub fn listRegisteredFeatures(self: *const Framework, allocator: std.mem.Allocator) RegistryError![]Feature| fn | source |
List all registered features.
pub const FrameworkBuilder| const | source |
Fluent builder for Framework initialization.
pub fn withDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Start with default configuration.
pub fn withGpu(self: *FrameworkBuilder, gpu_config: config_module.GpuConfig) *FrameworkBuilder| fn | source |
Enable GPU with configuration.
pub fn withGpuDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable GPU with defaults.
pub fn withIo(self: *FrameworkBuilder, io: std.Io) *FrameworkBuilder| fn | source |
Provide a shared I/O backend for the framework.
Pass the std.Io obtained from IoBackend.init.
pub fn withAi(self: *FrameworkBuilder, ai_config: config_module.AiConfig) *FrameworkBuilder| fn | source |
Enable AI with configuration.
pub fn withAiDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable AI with defaults.
pub fn withLlm(self: *FrameworkBuilder, llm_config: config_module.LlmConfig) *FrameworkBuilder| fn | source |
Enable LLM only.
pub fn withDatabase(self: *FrameworkBuilder, db_config: config_module.DatabaseConfig) *FrameworkBuilder| fn | source |
Enable database with configuration.
pub fn withDatabaseDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable database with defaults.
pub fn withNetwork(self: *FrameworkBuilder, net_config: config_module.NetworkConfig) *FrameworkBuilder| fn | source |
Enable network with configuration.
pub fn withNetworkDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable network with defaults.
pub fn withObservability(self: *FrameworkBuilder, obs_config: config_module.ObservabilityConfig) *FrameworkBuilder| fn | source |
Enable observability with configuration.
pub fn withObservabilityDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable observability with defaults.
pub fn withWeb(self: *FrameworkBuilder, web_config: config_module.WebConfig) *FrameworkBuilder| fn | source |
Enable web with configuration.
pub fn withWebDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable web with defaults.
pub fn withAnalytics(self: *FrameworkBuilder, analytics_cfg: config_module.AnalyticsConfig) *FrameworkBuilder| fn | source |
Enable analytics with configuration.
pub fn withAnalyticsDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable analytics with defaults.
pub fn withCloud(self: *FrameworkBuilder, cloud_config: config_module.CloudConfig) *FrameworkBuilder| fn | source |
Enable cloud with configuration.
pub fn withCloudDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable cloud with defaults.
pub fn withAuth(self: *FrameworkBuilder, auth_config: config_module.AuthConfig) *FrameworkBuilder| fn | source |
Enable auth with configuration.
pub fn withAuthDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable auth with defaults.
pub fn withMessaging(self: *FrameworkBuilder, msg_config: config_module.MessagingConfig) *FrameworkBuilder| fn | source |
Enable messaging with configuration.
pub fn withMessagingDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable messaging with defaults.
pub fn withCache(self: *FrameworkBuilder, cache_config: config_module.CacheConfig) *FrameworkBuilder| fn | source |
Enable cache with configuration.
pub fn withCacheDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable cache with defaults.
pub fn withStorage(self: *FrameworkBuilder, storage_config: config_module.StorageConfig) *FrameworkBuilder| fn | source |
Enable storage with configuration.
pub fn withStorageDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable storage with defaults.
pub fn withSearch(self: *FrameworkBuilder, search_config: config_module.SearchConfig) *FrameworkBuilder| fn | source |
Enable search with configuration.
pub fn withSearchDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable search with defaults.
pub fn withGateway(self: *FrameworkBuilder, gateway_cfg: config_module.GatewayConfig) *FrameworkBuilder| fn | source |
Enable gateway with configuration.
pub fn withGatewayDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable gateway with defaults.
pub fn withPages(self: *FrameworkBuilder, pages_cfg: config_module.PagesConfig) *FrameworkBuilder| fn | source |
Enable pages with configuration.
pub fn withPagesDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable pages with defaults.
pub fn withBenchmarks(self: *FrameworkBuilder, benchmarks_cfg: config_module.BenchmarksConfig) *FrameworkBuilder| fn | source |
Enable benchmarks with configuration.
pub fn withBenchmarksDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable benchmarks with defaults.
pub fn withMobile(self: *FrameworkBuilder, mobile_cfg: config_module.MobileConfig) *FrameworkBuilder| fn | source |
Enable mobile with configuration.
pub fn withMobileDefaults(self: *FrameworkBuilder) *FrameworkBuilder| fn | source |
Enable mobile with defaults.
pub fn withPlugins(self: *FrameworkBuilder, plugin_config: config_module.PluginConfig) *FrameworkBuilder| fn | source |
Configure plugins.
pub fn build(self: *FrameworkBuilder) Framework.Error!Framework| fn | source |
Build and initialize the framework.
If an I/O backend was supplied via withIo, it will be stored in the
resulting Framework instance.
Generated automatically by zig build gendocs
Use the $zig Codex skill for ABI Zig 0.16-dev syntax updates, modular build graph guidance, and targeted validation workflows.