Network: opt-in through an extended option, off by default - #786
Merged
Conversation
The OpenStation Network module loaded on every install, Network window included, whether or not the site belonged to a network. It is now gated the way games and agents are: a network extended option, off by default, read once on plugins_loaded by includes/network/bootstrap.php, which loads the six module files only when it is on. While off no keypair is minted, no route registered, no cron scheduled, no token minted or spent, the Network window stays out of the app registry, and a multisite keeps the site switcher it has on its own. Pairings already made survive a disable. The toggle sits in OpenStation Preferences, Features, Extended options, and the openstation_network_enabled filter lets a plugin decide in time.
…oads The shell screen reads openstation_hop_from through a constant the hop module defined, so with the module off every shell request died on an undefined constant. Both boot-arg constants move to the bootstrap.
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.
What it does
The OpenStation Network becomes opt-in. A new Enable OpenStation Network toggle in OpenStation Preferences → Features → Extended options, off by default, decides whether the network module loads at all. While it is off, the Network app is not in the dock, nothing network-related runs on the server, and a multisite keeps the site switcher it already has on its own.
Rationale
The module (#756, #782) loaded on every install, whether or not the site was part of a network: a keypair minted on first use, three REST routes, a cron hook, the hop redeem on
init, and the Network window in every dock. Most installs will never pair with another, and the pattern for that already exists in this codebase: games and AI agents are gated by an extended option and cost nothing while off.Implementation
Mirrors
includes/games/bootstrap.phpexactly:includes/network/bootstrap.phpreads thenetworkkey of the extended options bundle (openstation_network_enabled(), filteropenstation_network_enabled) and, onplugins_loadedpriority 5, requires the six module files only when it is on.desktop-mode.phprequires the bootstrap instead of the files.apps/network/network.os.phpreturnsnullbefore defining the app when the module is off, so the registry takes no window.openstation_multisite_payload()returnsnullfor a single site while off (no network, no switcher), the member entries andhopUrlare added only while on, andhopLinkOfferin the shell config isnullwithout the module.The toggle spends the same
$os->refresh_menu()the other extended options do, so the Network tile appears and disappears without a reload. Pairings, keys and links are options and user meta that survive a disable and are back when the option is on again.Behaviour change for installs already paired on #782: after this lands the network is off until an administrator turns it on, on each install.
Testing instructions
GET /wp-json/desktop-mode/v1/network/identityanswersrest_no_route, and on a single site Overview has no site switcher.Gates:
npm run build && npm run lint && npm run typecheck && npm run test:js, thennpm run env:start:tests && npm run lint:php && npm run test:php && npm run test:php:multisite && npm run env:stop:tests.test_the_network_is_off_by_default_and_its_option_turns_it_onpins the default and the payload guards on both shapes; the PHPUnit bootstrap enables the network for the rest of the suite, the way it does for games and agents.