Network-wide settings with per-site override cascade#418
Merged
Conversation
…cascade Introduces a network-level settings layer (get_site_option) for AI provider/model configuration so multisite installs can configure once and share across subsites — without requiring network activation. - NetworkSettings class: stores default_provider, default_model, and agent_models via get_site_option (network-wide on multisite, identical to get_option on single-site) - PluginSettings::resolve(): cascade that checks per-site first, falls back to network default, then hardcoded default - PluginSettings::getAgentModel(): updated to use the full cascade (site agent override → network agent override → site global → network global → empty) - SettingsAbilities: exposes network_settings in get-settings response and accepts network_settings in update-settings (super admin only on multisite) - uninstall.php: cleans up datamachine_network_settings on uninstall - 20 tests covering NetworkSettings CRUD, key validation, resolve cascade, and getAgentModel mixed scenarios
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a network-level settings layer so multisite installs can configure AI provider/model defaults once and share them across subsites — without requiring network activation.
This closes the last multisite gap from #382: AI provider settings were stuck in per-site
get_option(), requiring manual configuration on every subsite. Now they cascade: site → network → default.What changed
NetworkSettingsclass (inc/Core/NetworkSettings.php) — storesdefault_provider,default_model,agent_modelsviaget_site_option(). On single-site, this is identical toget_option()— zero impact.PluginSettings::resolve()— new cascade method: checks per-site value first, falls back to network default, then hardcoded default. Empty strings and empty arrays are treated as "not set" to allow the cascade to continue.PluginSettings::getAgentModel()— updated to use full cascade (site agent override → network agent override → site global default → network global default → empty)SettingsAbilities—get-settingsresponse now includesnetwork_settingsobject.update-settingsacceptsnetwork_settingsinput (requires super admin on multisite).uninstall.php—datamachine_network_settingsadded to network options cleanup list.Cascade diagram
Behavior
get_site_option()===get_option(), NetworkSettings is transparent.Tests
20 tests covering:
resolve()cascade (site wins, network fallback, both empty)getAgentModel()with mixed site/network overridesRelated