refactor!: remove all process-wide globals - #28
Merged
Conversation
…, runner - added await runtime.run(); - injected settings directly into conflict detection and resolution
- also make `Simulation` own explicit traffic, navigation, and console refs
- current command and sender state, scenario name, timestamps and commands are also now owned by `Minisky`.
…nav refs - make `OpenAP` own its traffic reference - make `Position` require explicit nav and traffic objects
- streaming is now directly driven by the owning `Simulation` after each step
- make `PluginManager` own discovered plugin records, loaded plugin state, plugin-created objects, hooks, timers, plugin command registration - note that we are still using the AST hacks (#24), it will be cleaned up in a separate PR - shared replaceable class catalog contains declaration metadata only, owned by the runtime - significantly pruned earlier escape hatches/compat wrappers
…untime`
- replaces `minisky.{init,traf,sim,scr,runner,navdb,_current,_activate}`
- replaces `minisky.stack.{current(),Stack,stack(),readscn(),showhelp(),`
`get_scenname(),_active_stack,Command.cmddict}`
- remove temp `minisky.core.varexplorer`, `minisky.tools.areafilter`
- replace module global fastapi router, mutable magnetic declination globals,
import-time runtime activation, standalone area filter instance, active
variable explorer, active command stack and registry alias.
- use `IntEnum` for `SimulationState`
…licit - make `MiniSky` owns independent python/numpy generators, and `SEED` should only affect that runtime - use `typing.Final` for magnetic declination - suppress openap warnings for now
reverts change in fdb334f also add some comments on deferred changes
best effort, skipping test_aero.py and test_detection.py for now
abc8747
force-pushed
the
pr-remove-globals
branch
from
July 28, 2026 14:55
47a0350 to
14fc7a2
Compare
This was referenced Jul 28, 2026
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.
Following #19 (comment), I was working on #24 but noticed that
miniskyrelies on mutable process-wide state everywhere, for example:minisky/docs/guides/python-api.md
Lines 10 to 15 in 142da23
Here,
minisky.init()mutates module-level variables such astraf,sim,scr,runner, andnavdb, which are then accessed throughout the project by importingminisky. Similar global state exists inCommand.cmddict,varexplorer.varlist, simulation hooks, and settings loaded at import time, resulting in implicit dependencies.These objects have no explicit owner or lifetime, and so tests/downstream applications must reset shared state manually. Initialisation depends on import order, and multiple independent simulators cannot safely exist in one process.
This is particularly problematic for plugins, which need a specific runtime to own their configuration, commands, hooks, resources, and teardown.
This PR fully migrates toward an explicit ownership root, removing virtually all singletons and process-global mutables. While it is a significant breaking change, this change is necessary for long-term health and paves the way for proper plugin development.
To migrate:
minisky.init(...)with MiniSky(settings, scenario=...) as runtimeminisky.load_plugins()runtime.load_plugins()minisky.trafruntime.trafficminisky.simruntime.simulationminisky.scrruntime.consoleminisky.runnerruntime.runnerminisky.navdbruntime.navigationminisky.stack.{stack(...),cmddict}runtime.commands.{stack(...),cmddict}runtime.pluginsvarexplorer.varlistruntime.variables.varlistruntime.areasruntime.replaceablesINIT,HOLD,OP,ENDSimulationState.{INIT,HOLD,OP,ENDenumsprefer_compiledsettingBefore:
After:
Note that multiple outstanding issues, such as
sys.pathmutation during plugin loading (see issue #24), command-list concurrency bugs, stream event wakeups are inherited and remain unfixed.