Skip to content

Network-wide settings with per-site override cascade#418

Merged
chubes4 merged 1 commit into
mainfrom
feature/network-settings
Feb 25, 2026
Merged

Network-wide settings with per-site override cascade#418
chubes4 merged 1 commit into
mainfrom
feature/network-settings

Conversation

@chubes4

@chubes4 chubes4 commented Feb 25, 2026

Copy link
Copy Markdown
Member

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

  • NetworkSettings class (inc/Core/NetworkSettings.php) — stores default_provider, default_model, agent_models via get_site_option(). On single-site, this is identical to get_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)
  • SettingsAbilitiesget-settings response now includes network_settings object. update-settings accepts network_settings input (requires super admin on multisite).
  • uninstall.phpdatamachine_network_settings added to network options cleanup list.

Cascade diagram

Per-site override  →  Network default  →  Hardcoded fallback
   (get_option)       (get_site_option)

Behavior

  • Single-site: Zero change. get_site_option() === get_option(), NetworkSettings is transparent.
  • Multisite (per-site activation): Set network defaults from any site with DM active. All DM-active sites inherit. Per-site overrides still work.
  • Multisite (network activation): Same behavior, all sites inherit.

Tests

20 tests covering:

  • NetworkSettings CRUD, key validation, merge behavior
  • resolve() cascade (site wins, network fallback, both empty)
  • getAgentModel() with mixed site/network overrides
  • Non-network keys are rejected from network storage

Related

…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
@chubes4 chubes4 merged commit dd3799e into main Feb 25, 2026
@chubes4 chubes4 deleted the feature/network-settings branch February 25, 2026 20:51
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