A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Refactor the user config data structures for consistency and clarity (#11191)
Martha Cryand2761d4b7dfb
diff --git a/marimo/_cli/config/commands.py b/marimo/_cli/config/commands.pyindex dfb7cf5f1c..5c66b50dc0 100644--- a/marimo/_cli/config/commands.py+++ b/marimo/_cli/config/commands.py@@ -9,7 +9,7 @@ from marimo._cli.config.utils import highlight_toml_headersfrom marimo._cli.help_formatter import ColoredCommand, ColoredGroupfrom marimo._cli.print import echo, greenfrom marimo._config.manager import (- UserConfigManager,+ UserConfigStore,get_default_config_manager,)from marimo._config.reader import find_nearest_pyproject_toml@@ -36,7 +36,7 @@ def show() -> None:config_manager = get_default_config_manager(current_path=current_path)# Save config if doesn't exist- UserConfigManager().save_config_if_missing()+ UserConfigStore().save_config_if_missing()# Show project overrides if they existproject_config_path = find_nearest_pyproject_toml(current_path)diff --git a/marimo/_config/manager.py b/marimo/_config/manager.pyindex 7a9293cbfc..5dc025ee47 100644--- a/marimo/_config/manager.py+++ b/marimo/_config/manager.py@@ -2,7 +2,6 @@from __future__ import annotationsimport os-from abc import abstractmethodfrom functools import cached_property, lru_cachefrom pathlib import Pathfrom typing import Any, cast@@ -27,6 +26,7 @@ from marimo._config.config import (from marimo._config.packages import PackageManagerKindfrom marimo._config.reader import (ALLOWED_SCRIPT_CONFIG_TOP_KEYS,+ ConfigReader,allowlist_script_config,find_nearest_pyproject_toml,get_marimo_config_from_pyproject_dict,@@ -35,13 +35,15 @@ from marimo._config.reader import (sanitize_pyproject_dict,strip_untrusted_config,)+from marimo._config.resolver import merge_config_patches, resolve_configfrom marimo._config.secrets import (- mask_secrets,- mask_secrets_partial,+ redact_secrets,+ redact_secrets_partial,remove_secret_placeholders,)from marimo._config.settings import GLOBAL_SETTINGSfrom marimo._config.utils import (+ deep_copy,get_or_create_user_config_path,is_trusted_user_config_path,)@@ -67,19 +69,32 @@ def get_default_config_manager(current_path = os.getcwd()return MarimoConfigManager(- UserConfigManager(),- ProjectConfigManager(current_path),- ScriptConfigManager(current_path),- EnvConfigManager(),- # Always merged last; see SecurityConfigManager.- SecurityConfigManager(),+ UserConfigStore(),+ PyprojectConfigReader(current_path),+ ScriptConfigReader(current_path),+ EnvConfigReader(),+ # Always merged last; see SecurityConfigReader.+ SecurityConfigReader(),)-class MarimoConfigReader:- @abstractmethod- def get_config(self, *, hide_secrets: bool = True) -> MarimoConfig:- """Get the configuration, optionally hiding secrets"""+class MarimoConfigManager:+ def __init__(+ self,+ user_config_mgr: UserConfigStore,+ *partials: ConfigReader,+ ) -> None:+ self.user_config_mgr = user_config_mgr+ # Security partials are pulled out and always merged last (after every+ # other partial, including any added by with_overrides()), so the+ # enforcements they apply cannot be re-enabled by a lower-priority+ # config source. See SecurityConfigReader.+ self.partials = tuple(+ p for p in partials if not isinstance(p, SecurityConfigReader)+ )+ self.security_partials = tuple(+ p for p in partials if isinstance(p, SecurityConfigReader)+ )# Convenience methods for common access patterns@@ -127,28 +142,10 @@ class MarimoConfigReader:return self._config["experimental"]return {}--class MarimoConfigManager(MarimoConfigReader):- def __init__(- self,- user_config_mgr: UserConfigManager,- *partials: PartialMarimoConfigReader,- ) -> None:- self.user_config_mgr = user_config_mgr- # Security partials are pulled out and always merged last (after every- # other partial, including any added by with_overrides()), so the- # enforcements they apply cannot be re-enabled by a lower-priority- # config source. See SecurityConfigManager.- self.partials = tuple(- p for p in partials if not isinstance(p, SecurityConfigManager)- )- self.security_partials = tuple(- p for p in partials if isinstance(p, SecurityConfigManager)- )-def get_user_config(self, *, hide_secrets: bool = True) -> MarimoConfig:"""Get the user configuration"""- return self.user_config_mgr.get_config(hide_secrets=hide_secrets)+ config = resolve_config(DEFAULT_CONFIG, (self.user_config_mgr.read(),))+ return redact_secrets(config) if hide_secrets else configdef get_config_overrides(self, *, hide_secrets: bool = True@@ -158,44 +155,39 @@ class MarimoConfigManager(MarimoConfigReader):Security partials are merged last, so the enforcements they applycannot be overridden by any other config source."""- all_partials = (*self.partials, *self.security_partials)- if not all_partials:- return {}- if len(all_partials) == 1:- return all_partials[0].get_config(hide_secrets=hide_secrets)- result: MarimoConfig = cast(MarimoConfig, {})- for partial in all_partials:- result = merge_config(- result, partial.get_config(hide_secrets=hide_secrets)- )- return cast(PartialMarimoConfig, result)+ config = self._read_overrides()+ return redact_secrets_partial(config) if hide_secrets else config++ def _read_overrides(self) -> PartialMarimoConfig:+ return merge_config_patches(+ reader.read()+ for reader in (*self.partials, *self.security_partials)+ )def get_config_defaults(self, *, hide_secrets: bool = True) -> PartialMarimoConfig:- """Get the defaults the partials compute, merged beneath the user configuration"""- result: MarimoConfig = cast(MarimoConfig, {})- for partial in (*self.partials, *self.security_partials):- result = merge_config(- result, partial.get_defaults(hide_secrets=hide_secrets)- )- return cast(PartialMarimoConfig, result)+ """Get contextual fallbacks, merged beneath explicit configuration."""+ config = self._read_defaults()+ return redact_secrets_partial(config) if hide_secrets else config++ def _read_defaults(self) -> PartialMarimoConfig:+ return merge_config_patches(+ _contextual_defaults(reader)+ for reader in (*self.partials, *self.security_partials)+ )def get_config(self, *, hide_secrets: bool = True) -> MarimoConfig:"""Get the configuration, by merging the user configuration and the configuration overrides"""# NB. Defaults go under the user configuration, overrides over it. A# default a partial computes from the notebook location is not# something anyone wrote, so it must lose to a value the user set.- return merge_config(- merge_config(- cast(- MarimoConfig,- self.get_config_defaults(hide_secrets=hide_secrets),- ),- self.get_user_config(hide_secrets=hide_secrets),- ),- self.get_config_overrides(hide_secrets=hide_secrets),+ config = resolve_config(+ DEFAULT_CONFIG,+ (self.user_config_mgr.read(), self._read_overrides()),+ fallback=self._read_defaults(),)+ return redact_secrets(config) if hide_secrets else configdef save_config(self, config: MarimoConfig | PartialMarimoConfig@@ -211,16 +203,13 @@ class MarimoConfigManager(MarimoConfigReader):The new override is appended after the existing partials but before thesecurity partials, which the constructor keeps last so they always win."""- return self.with_partial(MarimoConfigReaderWithOverrides(overrides))+ return self.with_partial(OverrideConfigReader(overrides))- def with_partial(- self, partial: PartialMarimoConfigReader- ) -> MarimoConfigManager:+ def with_partial(self, partial: ConfigReader) -> MarimoConfigManager:"""Get a new config manager with the given partial reader layered on- Unlike `with_overrides`, the reader keeps answering `hide_secrets`- itself, so a masked read does not become the value an unmasked read- returns.+ The source is read unmasked during resolution; masking is applied only+ when configuration values are returned to callers."""return MarimoConfigManager(self.user_config_mgr,@@ -230,22 +219,8 @@ class MarimoConfigManager(MarimoConfigReader):)-@abstractmethod-class PartialMarimoConfigReader:- @abstractmethod- def get_config(self, *, hide_secrets: bool = True) -> PartialMarimoConfig:- """Get the configuration, as a partial configuration"""-- def get_defaults(- self, *, hide_secrets: bool = True- ) -> PartialMarimoConfig:- """Get the values that apply when no configuration layer set them"""- del hide_secrets # no defaults, so nothing to mask- return {}---class ProjectConfigManager(PartialMarimoConfigReader):- """Read the project configuration"""+class PyprojectConfigReader(ConfigReader):+ """Read `tool.marimo` settings from the nearest `pyproject.toml`."""def __init__(self, start_path: str) -> None:self.start_path = start_path@@ -264,33 +239,12 @@ class ProjectConfigManager(PartialMarimoConfigReader):start_path = Path(self.start_path)return start_path if start_path.is_dir() else start_path.parent- def get_defaults(- self, *, hide_secrets: bool = True- ) -> PartialMarimoConfig:- """Get the `.env` next to the project, loaded when no layer set `dotenv`"""- root = self._dotenv_root- if self.pyproject_path is None and _is_home_directory(root):- # NB. Without a pyproject.toml the anchor is wherever the notebook- # or `marimo edit` sits. For ~ that would load ~/.env and list its- # keys in the secrets panel, so the default is skipped there.- return {}- # NB. Emitted as a default, not from get_config(): get_config() is an- # override layer over the user configuration, so a path nobody wrote- # would outrank the user's own runtime.dotenv and would show up as a- # project override in the settings editor.- defaults = cast(- PartialMarimoConfig,- {"runtime": {"dotenv": [str((root / ".env").absolute())]}},- )- if hide_secrets:- return mask_secrets_partial(defaults)- return defaults+ def read(self) -> PartialMarimoConfig:+ return cast(PartialMarimoConfig, deep_copy(self._read_config()))- # It is safe to cache this config, as we only read from the pyproject.toml- # and never update it. If the user updates the pyproject.toml,- # it is ok to expect updates to be reflected after a server restart.+ # Source changes are picked up after a server restart.@lru_cache(maxsize=2) # noqa: B019- def get_config(self, *, hide_secrets: bool = True) -> PartialMarimoConfig:+ def _read_config(self) -> PartialMarimoConfig:try:project_config = (read_pyproject_marimo_config(self.pyproject_path)@@ -311,8 +265,6 @@ class ProjectConfigManager(PartialMarimoConfigReader):LOGGER.warning("Failed to read project config: %s", e)return {}- if hide_secrets:- return mask_secrets_partial(project_config)return project_configdef _resolve_pythonpath(@@ -349,8 +301,7 @@ class ProjectConfigManager(PartialMarimoConfigReader):) -> PartialMarimoConfig:runtime = config.get("runtime", cast(RuntimeConfig, {}))if "dotenv" not in runtime:- # NB. The default is emitted by get_defaults() instead, which- # ranks below the user configuration.+ # The manager supplies contextual defaults below explicit settings.return configdotenv = runtime["dotenv"]@@ -415,7 +366,7 @@ class ProjectConfigManager(PartialMarimoConfigReader):}-class EnvConfigManager(PartialMarimoConfigReader):+class EnvConfigReader(ConfigReader):def _maybe_override_from_env(self,key: str,@@ -444,7 +395,7 @@ class EnvConfigManager(PartialMarimoConfigReader):current[path[-1]] = valuereturn- def get_config(self, *, hide_secrets: bool = True) -> PartialMarimoConfig:+ def read(self) -> PartialMarimoConfig:"""Get the configuration, as a partial configuration"""project_config: PartialMarimoConfig = {}# We could do this dynamically, but list explicitly for now to reduce@@ -460,12 +411,10 @@ class EnvConfigManager(PartialMarimoConfigReader):project_config,allowed_values=("websocket", "sse"),)- if hide_secrets:- return mask_secrets_partial(project_config)return project_config-class SecurityConfigManager(PartialMarimoConfigReader):+class SecurityConfigReader(ConfigReader):"""Machine-wide security enforcements that always take precedence.`MarimoConfigManager` merges partials of this type last, after every other@@ -478,8 +427,7 @@ class SecurityConfigManager(PartialMarimoConfigReader):handles `MARIMO_RESTRICT_SHARING`."""- def get_config(self, *, hide_secrets: bool = True) -> PartialMarimoConfig:- del hide_secrets # no secrets are produced here+ def read(self) -> PartialMarimoConfig:config: PartialMarimoConfig = {}if GLOBAL_SETTINGS.RESTRICT_SHARING:# Hide every external code-sharing affordance (shareable WASM@@ -495,7 +443,7 @@ class SecurityConfigManager(PartialMarimoConfigReader):return config-class ScriptConfigManager(PartialMarimoConfigReader):+class ScriptConfigReader(ConfigReader):"""Read the script configuration following PEP 723This looks like a pyproject.toml serialized as a comment in the header@@ -505,25 +453,12 @@ class ScriptConfigManager(PartialMarimoConfigReader):def __init__(self, filename: str | None) -> None:self.filename = filename- def get_defaults(- self, *, hide_secrets: bool = True- ) -> PartialMarimoConfig:- """Get the `.env` next to the notebook, loaded when no layer set `dotenv`"""- # NB. In a directory workspace the project manager anchors on the- # directory marimo edit opened, not on the notebook a session runs.- # Script config already outranks project config, so the notebook's- # default outranks the workspace's the same way.- if self.filename is None:- return {}- return ProjectConfigManager(self.filename).get_defaults(- hide_secrets=hide_secrets- )+ def read(self) -> PartialMarimoConfig:+ return cast(PartialMarimoConfig, deep_copy(self._read_config()))- # It is safe to cache this config, as we only read from the script- # and never update it. If the user updates the script,- # it is ok to expect updates to be reflected after a server restart.+ # Source changes are picked up after a server restart.@lru_cache(maxsize=2) # noqa: B019- def get_config(self, *, hide_secrets: bool = True) -> PartialMarimoConfig:+ def _read_config(self) -> PartialMarimoConfig:if self.filename is None:return {}try:@@ -556,7 +491,7 @@ class ScriptConfigManager(PartialMarimoConfigReader):if marimo_config is None:return {}- marimo_config = ProjectConfigManager(+ marimo_config = PyprojectConfigReader(self.filename)._resolve_dotenv(marimo_config)@@ -567,12 +502,10 @@ class ScriptConfigManager(PartialMarimoConfigReader):LOGGER.warning("Failed to read script config: %s", e)return {}- if hide_secrets:- return mask_secrets_partial(marimo_config)return marimo_config-class UserConfigManager(MarimoConfigReader):+class UserConfigStore(ConfigReader):"""Read and write the user configuration"""def save_config(@@ -585,7 +518,7 @@ class UserConfigManager(MarimoConfigReader):# Remove the secret placeholders from the incoming configconfig = remove_secret_placeholders(config)# Merge the current config with the new config- current_config = self._load_config()+ current_config = resolve_config(DEFAULT_CONFIG, (self.read(),))merged = merge_config(current_config, config)# None-as-delete: any key whose merged value is None (typically because# the incoming config explicitly sent null) is removed from disk. Lets@@ -606,16 +539,14 @@ class UserConfigManager(MarimoConfigReader):except Exception as e:LOGGER.warning("Failed to save config: %s", e)- def get_config(self, *, hide_secrets: bool = True) -> MarimoConfig:- current_config = self._load_config()- if hide_secrets:- return mask_secrets(current_config)- return current_config+ def read(self) -> PartialMarimoConfig:+ """Read explicit user settings without applying defaults or masking."""+ return cast(PartialMarimoConfig, deep_copy(self._load_config()))def get_config_path(self) -> str:return get_or_create_user_config_path()- def _load_config(self) -> MarimoConfig:+ def _load_config(self) -> PartialMarimoConfig:"""Load configuration, taking into account user config file, if any."""@@ -634,7 +565,7 @@ class UserConfigManager(MarimoConfigReader):except Exception as e:LOGGER.error("Failed to read user config at %s", path)LOGGER.error(str(e))- return DEFAULT_CONFIG+ return {}if not is_trusted_user_config_path(path):# A `.marimo.toml` discovered by walking up from the cwd is# project-origin, not user-owned. Strip its cache-trust keys@@ -642,22 +573,41 @@ class UserConfigManager(MarimoConfigReader):user_config = strip_untrusted_config(user_config, is_user_layer=True)- return merge_default_config(_drop_hollow_dotenv(user_config))+ return _drop_hollow_dotenv(user_config)else:LOGGER.debug("No config found; loading default settings.")- return DEFAULT_CONFIG+ return {}-class MarimoConfigReaderWithOverrides(PartialMarimoConfigReader):+class OverrideConfigReader(ConfigReader):"""Read the configuration, with overrides"""def __init__(self, override_config: PartialMarimoConfig) -> None:- self.override_config = override_config+ self.override_config = deep_copy(override_config)- def get_config(self, *, hide_secrets: bool = True) -> PartialMarimoConfig:- if hide_secrets:- return mask_secrets_partial(self.override_config)- return self.override_config+ def read(self) -> PartialMarimoConfig:+ return cast(PartialMarimoConfig, deep_copy(self.override_config))+++def _contextual_defaults(reader: ConfigReader) -> PartialMarimoConfig:+ """Infer dotenv paths separately from settings supplied by a source."""+ if isinstance(reader, ScriptConfigReader):+ if reader.filename is None:+ return {}+ project = PyprojectConfigReader(reader.filename)+ elif isinstance(reader, PyprojectConfigReader):+ project = reader+ else:+ return {}++ root = project._dotenv_root+ if project.pyproject_path is None and _is_home_directory(root):+ # Avoid exposing ~/.env merely because a workspace opened at home.+ return {}+ return cast(+ PartialMarimoConfig,+ {"runtime": {"dotenv": [str((root / ".env").absolute())]}},+ )def _is_home_directory(path: Path) -> bool:diff --git a/marimo/_config/reader.py b/marimo/_config/reader.pyindex 64cf10146e..5d9c06206b 100644--- a/marimo/_config/reader.py+++ b/marimo/_config/reader.py@@ -1,6 +1,7 @@# Copyright 2026 Marimo. All rights reserved.from __future__ import annotations+from abc import ABC, abstractmethodfrom pathlib import Pathfrom typing import Any, cast@@ -11,6 +12,18 @@ from marimo._utils.toml import toml_readerLOGGER = _loggers.marimo_logger()+class ConfigReader(ABC):+ """Read explicitly supplied settings without filling in defaults.++ Sources parse and normalize their own values. Precedence and computed+ defaults are handled separately by the configuration manager.+ """++ @abstractmethod+ def read(self) -> PartialMarimoConfig:+ """Read a sparse, unmasked configuration from this source."""++def read_marimo_config(path: str) -> PartialMarimoConfig:"""Read the marimo.toml configuration."""return cast(PartialMarimoConfig, toml_reader.read(path))diff --git a/marimo/_config/resolver.py b/marimo/_config/resolver.pynew file mode 100644index 0000000000..0c72f0bc86--- /dev/null+++ b/marimo/_config/resolver.py@@ -0,0 +1,43 @@+# Copyright 2026 Marimo. All rights reserved.+from __future__ import annotations++from typing import TYPE_CHECKING, cast++from marimo._config.config import (+ MarimoConfig,+ PartialMarimoConfig,+ merge_config,+)+from marimo._config.utils import deep_copy++if TYPE_CHECKING:+ from collections.abc import Iterable+++def merge_config_patches(+ patches: Iterable[PartialMarimoConfig],+) -> PartialMarimoConfig:+ """Merge sparse patches in order, with later patches taking precedence."""+ merged = cast(MarimoConfig, {})+ for patch in patches:+ merged = merge_config(merged, deep_copy(patch))+ return cast(PartialMarimoConfig, deep_copy(merged))+++def resolve_config(+ defaults: MarimoConfig,+ patches: Iterable[PartialMarimoConfig],+ *,+ fallback: PartialMarimoConfig | None = None,+) -> MarimoConfig:+ """Resolve defaults and ordered patches without reading or masking sources.++ Contextual fallback values fill gaps in the schema defaults. Explicit+ patches take precedence over both kinds of defaults.+ """+ config = merge_config(+ cast(MarimoConfig, deep_copy(fallback or {})), deep_copy(defaults)+ )+ for patch in patches:+ config = merge_config(config, deep_copy(patch))+ return configdiff --git a/marimo/_config/secrets.py b/marimo/_config/secrets.pyindex 36aa151d77..8910cf32a9 100644--- a/marimo/_config/secrets.py+++ b/marimo/_config/secrets.py@@ -11,11 +11,16 @@ SECRET_PLACEHOLDER = "********"# TODO: mypy doesn't like using @overload here-def mask_secrets_partial(config: PartialMarimoConfig) -> PartialMarimoConfig:- return cast(PartialMarimoConfig, mask_secrets(cast(MarimoConfig, config)))+def redact_secrets_partial(config: PartialMarimoConfig) -> PartialMarimoConfig:+ """Return a sparse configuration copy with sensitive values redacted."""+ return cast(+ PartialMarimoConfig, redact_secrets(cast(MarimoConfig, config))+ )++def redact_secrets(config: MarimoConfig) -> MarimoConfig:+ """Return a configuration copy with sensitive values redacted."""-def mask_secrets(config: MarimoConfig) -> MarimoConfig:def deep_remove_from_path(path: list[str], obj: dict[str, Any] | Any) -> None:diff --git a/marimo/_config/settings.py b/marimo/_config/settings.pyindex 77caceb58b..4e6c1a2374 100644--- a/marimo/_config/settings.py+++ b/marimo/_config/settings.py@@ -46,7 +46,7 @@ class GlobalSettings:)# Hide all external code-sharing affordances (shareable WASM links, molab,# HTML sharing) across every notebook session. Enforced by- # SecurityConfigManager, which MarimoConfigManager merges after all other+ # SecurityConfigReader, which MarimoConfigManager merges after all other# config sources, so it cannot be re-enabled by any config file or runtime# override. Intended for machine-wide enforcement set by infra admins in a# devpod or container spec.diff --git a/marimo/_lint/linter.py b/marimo/_lint/linter.pyindex 93f5573c90..4104cd6797 100644--- a/marimo/_lint/linter.py+++ b/marimo/_lint/linter.py@@ -110,12 +110,10 @@ class Linter:if self._explicit_rules:return self.rule_engine- from marimo._config.manager import ScriptConfigManager+ from marimo._config.manager import ScriptConfigReadertry:- file_config = ScriptConfigManager(file_path).get_config(- hide_secrets=False- )+ file_config = ScriptConfigReader(file_path).read()except Exception:return self.rule_enginediff --git a/marimo/_pyodide/bootstrap.py b/marimo/_pyodide/bootstrap.pyindex 65a72ab717..5b01e9ad1c 100644--- a/marimo/_pyodide/bootstrap.py+++ b/marimo/_pyodide/bootstrap.py@@ -103,13 +103,11 @@ def create_session(# Lazy import to decrease startup timefrom marimo._config.config import merge_default_config- from marimo._config.manager import ScriptConfigManager+ from marimo._config.manager import ScriptConfigReader# Add default configuser_config = merge_default_config(user_config)- script_config = ScriptConfigManager(filename).get_config(- hide_secrets=False- )+ script_config = ScriptConfigReader(filename).read()# Merge with inline script-metadata configuser_config = merge_config(user_config, script_config)diff --git a/marimo/_server/api/deps.py b/marimo/_server/api/deps.pyindex 14109b94d6..3cd6f78669 100644--- a/marimo/_server/api/deps.py+++ b/marimo/_server/api/deps.py@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Any, castfrom marimo import _loggers as loggersfrom marimo._cli.tips import CliTip-from marimo._config.manager import MarimoConfigManager, ScriptConfigManager+from marimo._config.manager import MarimoConfigManager, ScriptConfigReaderfrom marimo._server.config import StarletteServerStatefrom marimo._server.session_manager import SessionManagerfrom marimo._server.tokens import SkewProtectionToken@@ -224,7 +224,7 @@ class AppState(AppStateBase):config_manager = super().config_manager# The file key can be relative to the workspace directory, so resolve# it to a validated absolute path before reading inline script- # metadata — otherwise ScriptConfigManager would read relative to the+ # metadata — otherwise ScriptConfigReader would read relative to the# server's cwd. New/unsaved or missing files have no inline config to# apply; let other rejections (e.g. path traversal) propagate.try:@@ -236,5 +236,5 @@ class AppState(AppStateBase):if resolved is None:return config_managerreturn config_manager.with_overrides(- ScriptConfigManager(resolved).get_config()+ ScriptConfigReader(resolved).read())diff --git a/marimo/_server/lsp.py b/marimo/_server/lsp.pyindex 394e5d9c1d..a9dd3e9ea9 100644--- a/marimo/_server/lsp.py+++ b/marimo/_server/lsp.py@@ -15,7 +15,7 @@ from typing import Any, Literal, castfrom marimo import _loggersfrom marimo._config.config import MarimoConfig-from marimo._config.manager import MarimoConfigReader+from marimo._config.manager import MarimoConfigManagerfrom marimo._config.settings import GLOBAL_SETTINGSfrom marimo._dependencies.dependencies import DependencyManagerfrom marimo._messaging.notification import AlertNotification@@ -816,7 +816,7 @@ class CompositeLspServer(LspServer):def __init__(self,- config_reader: MarimoConfigReader,+ config_reader: MarimoConfigManager,min_port: int,) -> None:self.config_reader = config_readerdiff --git a/marimo/_session/managers/app_host.py b/marimo/_session/managers/app_host.pyindex 2a4f89b8cb..63fa0270e8 100644--- a/marimo/_session/managers/app_host.py+++ b/marimo/_session/managers/app_host.py@@ -25,7 +25,7 @@ if TYPE_CHECKING:import threadingfrom marimo._ast.cell import CellConfig- from marimo._config.manager import MarimoConfigReader+ from marimo._config.manager import MarimoConfigManagerfrom marimo._runtime.commands import AppMetadatafrom marimo._session.app_host.host import AppHostfrom marimo._types.ids import CellId_t@@ -161,7 +161,7 @@ class AppHostKernelManager(KernelManager):mode: SessionMode,configs: dict[CellId_t, CellConfig],app_metadata: AppMetadata,- config_manager: MarimoConfigReader,+ config_manager: MarimoConfigManager,redirect_console_to_browser: bool,) -> None:self._app_host = app_hostdiff --git a/marimo/_session/managers/ipc.py b/marimo/_session/managers/ipc.pyindex 83e1a3998c..41149f5aef 100644--- a/marimo/_session/managers/ipc.py+++ b/marimo/_session/managers/ipc.py@@ -20,7 +20,7 @@ from uuid import uuid4from marimo import _loggersfrom marimo._config.config import VenvConfig-from marimo._config.manager import MarimoConfigReader+from marimo._config.manager import MarimoConfigManagerfrom marimo._config.settings import GLOBAL_SETTINGSfrom marimo._environments.overlay import runtime_overlayfrom marimo._messaging.notification import (@@ -62,7 +62,7 @@ if TYPE_CHECKING:LOGGER = _loggers.marimo_logger()-def _get_venv_config(config_manager: MarimoConfigReader) -> VenvConfig:+def _get_venv_config(config_manager: MarimoConfigManager) -> VenvConfig:"""Get the [tool.marimo.venv] config from a config manager."""config = config_manager.get_config(hide_secrets=False)return cast(VenvConfig, config.get("venv", {}))@@ -275,7 +275,7 @@ class IPCKernelManagerImpl(KernelManager):mode: SessionMode,configs: dict[CellId_t, CellConfig],app_metadata: AppMetadata,- config_manager: MarimoConfigReader,+ config_manager: MarimoConfigManager,redirect_console_to_browser: bool = True,on_notification: Callable[[NotificationMessage], None] | None = None,) -> None:diff --git a/marimo/_session/managers/kernel.py b/marimo/_session/managers/kernel.pyindex 8cd722065a..a8a9d0146c 100644--- a/marimo/_session/managers/kernel.py+++ b/marimo/_session/managers/kernel.py@@ -27,7 +27,7 @@ from marimo._utils.typed_connection import TypedConnectionif TYPE_CHECKING:from marimo._ast.cell import CellConfig- from marimo._config.manager import MarimoConfigReader+ from marimo._config.manager import MarimoConfigManagerfrom marimo._runtime.commands import AppMetadatafrom marimo._runtime.virtual_file import VirtualFileStorageTypefrom marimo._types.ids import CellId_t@@ -49,7 +49,7 @@ class KernelManagerImpl(KernelManager):mode: SessionMode,configs: dict[CellId_t, CellConfig],app_metadata: AppMetadata,- config_manager: MarimoConfigReader,+ config_manager: MarimoConfigManager,virtual_file_storage: VirtualFileStorageType | None,redirect_console_to_browser: bool,) -> None:diff --git a/marimo/_session/session.py b/marimo/_session/session.pyindex 53f6fe6fcc..2b415c6d35 100644--- a/marimo/_session/session.py+++ b/marimo/_session/session.py@@ -13,7 +13,7 @@ from typing import TYPE_CHECKINGfrom uuid import uuid4from marimo import _loggers-from marimo._config.manager import MarimoConfigManager, ScriptConfigManager+from marimo._config.manager import MarimoConfigManager, ScriptConfigReaderfrom marimo._core.ids import mintfrom marimo._messaging.notebook.document import NotebookDocumentfrom marimo._messaging.notification import (@@ -115,7 +115,7 @@ class SessionImpl(Session):# its masked get_config() would turn runtime.dotenv into [] and that# empty list would then win the merge the kernel reads unmasked.config_manager = config_manager.with_partial(- ScriptConfigManager(app_file_manager.path)+ ScriptConfigReader(app_file_manager.path))config = config_manager.get_config(hide_secrets=False)configured_venv = config.get("venv", {}).get("path")diff --git a/tests/_config/test_config_snapshots.py b/tests/_config/test_config_snapshots.pyindex cf8fbb95a7..cff389e830 100644--- a/tests/_config/test_config_snapshots.py+++ b/tests/_config/test_config_snapshots.py@@ -17,9 +17,9 @@ from inline_snapshot import snapshotfrom marimo._config import manager as config_modulefrom marimo._config.config import DEFAULT_CONFIGfrom marimo._config.manager import (- EnvConfigManager,- ProjectConfigManager,- ScriptConfigManager,+ EnvConfigReader,+ PyprojectConfigReader,+ ScriptConfigReader,get_default_config_manager,)from marimo._config.settings import GLOBAL_SETTINGS@@ -232,9 +232,7 @@ def test_layered_configuration_snapshot("resolved_unmasked": manager.get_config(hide_secrets=False),"user_masked": manager.get_user_config(),"overrides_unmasked": manager.get_config_overrides(hide_secrets=False),- "script_unmasked": ScriptConfigManager(str(notebook)).get_config(- hide_secrets=False- ),+ "script_unmasked": ScriptConfigReader(str(notebook)).read(),}assert normalized(views, config_tree) == snapshot({@@ -726,9 +724,7 @@ def test_invalid_and_missing_inputs_snapshot(config_tree: Path) -> None:pyproject = project / "pyproject.toml"if contents is not None:pyproject.write_text(contents, encoding="utf-8")- cases[name] = ProjectConfigManager(str(project)).get_config(- hide_secrets=False- )+ cases[name] = PyprojectConfigReader(str(project)).read()for name, contents in [("missing_script", None),("no_metadata", "import marimo\n"),@@ -736,9 +732,7 @@ def test_invalid_and_missing_inputs_snapshot(config_tree: Path) -> None:]:if contents is not None:notebook.write_text(contents, encoding="utf-8")- cases[name] = ScriptConfigManager(str(notebook)).get_config(- hide_secrets=False- )+ cases[name] = ScriptConfigReader(str(notebook)).read()assert cases == snapshot({"missing": {},@@ -766,7 +760,7 @@ def test_environment_snapshot(monkeypatch.setenv("_MARIMO_CONFIG_OVERLOAD_RUNTIME_AUTO_INSTANTIATE", instantiate)- cases[transport] = EnvConfigManager().get_config(hide_secrets=False)+ cases[transport] = EnvConfigReader().read()assert cases == snapshot({"sse": {@@ -810,9 +804,7 @@ def test_trust_origins_snapshot(config_tree: Path) -> None:project_file.write_text(settings.replace("[", "[tool.marimo."), encoding="utf-8")- cases["pyproject"] = ProjectConfigManager(str(project_file)).get_config(- hide_secrets=False- )+ cases["pyproject"] = PyprojectConfigReader(str(project_file)).read()assert cases == snapshot({"home": {@@ -1080,7 +1072,7 @@ def test_dotenv_workspace_session_snapshot(config_tree: Path) -> None:(project / "pyproject.toml").write_text("", encoding="utf-8")manager = get_default_config_manager(current_path=str(project))session = manager.with_partial(- ScriptConfigManager(str(script) if script is not None else None)+ ScriptConfigReader(str(script) if script is not None else None))cases[name] = {"workspace": manager.get_config(hide_secrets=False)["runtime"].get(diff --git a/tests/_config/test_manager.py b/tests/_config/test_manager.pyindex 9b6a295cde..75dc271f7c 100644--- a/tests/_config/test_manager.py+++ b/tests/_config/test_manager.py@@ -10,13 +10,13 @@ import pytestfrom marimo._config.config import PartialMarimoConfig, merge_default_configfrom marimo._config.manager import (- EnvConfigManager,+ EnvConfigReader,MarimoConfigManager,- MarimoConfigReaderWithOverrides,- ProjectConfigManager,- ScriptConfigManager,- SecurityConfigManager,- UserConfigManager,+ OverrideConfigReader,+ PyprojectConfigReader,+ ScriptConfigReader,+ SecurityConfigReader,+ UserConfigStore,get_default_config_manager,)from marimo._config.settings import GLOBAL_SETTINGS@@ -28,14 +28,14 @@ F = TypeVar("F", bound=Callable[..., Any])def restore_config(f: F) -> F:- config = UserConfigManager().get_config()+ config = MarimoConfigManager(UserConfigStore()).get_user_config()@wraps(f)def wrapper(*args: Any, **kwargs: Any) -> Any:try:return f(*args, **kwargs)finally:- UserConfigManager().save_config(config)+ UserConfigStore().save_config(config)return wrapper # type: ignore@@ -44,7 +44,7 @@ def restore_config(f: F) -> F:@patch("tomlkit.dump")def test_save_config(mock_dump: Any) -> None:mock_config = merge_default_config(PartialMarimoConfig())- manager = UserConfigManager()+ manager = UserConfigStore()manager._load_config = lambda: mock_configresult = manager.save_config(mock_config)@@ -69,7 +69,7 @@ def test_save_config_is_deterministic(tmp_path: Path) -> None:from marimo._config.config import MarimoConfigconfig_path = tmp_path / "marimo.toml"- manager = UserConfigManager()+ manager = UserConfigStore()manager.get_config_path = lambda: str(config_path) # type: ignore[method-assign]a = PartialMarimoConfig(@@ -174,7 +174,7 @@ def test_save_config_none_deletes_key(mock_dump: Any) -> None:mock_config = merge_default_config(PartialMarimoConfig(ai={"max_tokens": 8192, "rules": "be terse"}))- manager = UserConfigManager()+ manager = UserConfigStore()manager._load_config = lambda: mock_configmanager.save_config(@@ -199,7 +199,7 @@ def test_save_config_with_none_does_not_raise(tmp_path: Path) -> None:mock_config = merge_default_config(PartialMarimoConfig(ai={"max_tokens": 8192, "rules": "be terse"}))- manager = UserConfigManager()+ manager = UserConfigStore()manager._load_config = lambda: mock_configwith patch.object(@@ -218,10 +218,10 @@ def test_user_config_drops_hollow_dotenv(tmp_path: Path) -> None:"""An empty runtime.dotenv on disk is a masked value, so it is ignored."""config_path = tmp_path / "marimo.toml"config_path.write_text("[runtime]\ndotenv = []\n")- manager = UserConfigManager()+ manager = UserConfigStore()manager.get_config_path = lambda: str(config_path) # type: ignore[method-assign]- config = manager.get_config(hide_secrets=False)+ config = MarimoConfigManager(manager).get_user_config(hide_secrets=False)assert "dotenv" not in config["runtime"]@@ -229,10 +229,10 @@ def test_user_config_keeps_populated_dotenv(tmp_path: Path) -> None:config_path = tmp_path / "marimo.toml"dotenv = tmp_path / ".env.user"config_path.write_text(f'[runtime]\ndotenv = ["{dotenv.as_posix()}"]\n')- manager = UserConfigManager()+ manager = UserConfigStore()manager.get_config_path = lambda: str(config_path) # type: ignore[method-assign]- config = manager.get_config(hide_secrets=False)+ config = MarimoConfigManager(manager).get_user_config(hide_secrets=False)assert config["runtime"]["dotenv"] == [dotenv.as_posix()]@@ -252,7 +252,7 @@ def test_drop_none_values_strips_nested_none() -> None:@patch("tomlkit.dump")def test_can_save_secrets(mock_dump: Any) -> None:mock_config = merge_default_config(PartialMarimoConfig())- manager = UserConfigManager()+ manager = UserConfigStore()manager._load_config = lambda: mock_confignew_config = manager.save_config(@@ -281,15 +281,22 @@ def test_can_save_secrets(mock_dump: Any) -> None:@restore_configdef test_can_read_secrets() -> None:- manager = UserConfigManager()+ manager = UserConfigStore()mock_config = merge_default_config(PartialMarimoConfig(ai={"open_ai": {"api_key": "super_secret"}}))manager._load_config = lambda: mock_config- assert manager.get_config()["ai"]["open_ai"]["api_key"] == "********"assert (- manager.get_config(hide_secrets=False)["ai"]["open_ai"]["api_key"]+ MarimoConfigManager(manager).get_user_config()["ai"]["open_ai"][+ "api_key"+ ]+ == "********"+ )+ assert (+ MarimoConfigManager(manager).get_user_config(hide_secrets=False)["ai"][+ "open_ai"+ ]["api_key"]== "super_secret")@@ -297,10 +304,10 @@ def test_can_read_secrets() -> None:@restore_configdef test_get_config() -> None:mock_config = merge_default_config(PartialMarimoConfig())- manager = UserConfigManager()+ manager = UserConfigStore()manager._load_config = lambda: mock_config- result = manager.get_config()+ result = MarimoConfigManager(manager).get_user_config()assert result == mock_config@@ -308,12 +315,12 @@ def test_get_config() -> None:@restore_configdef test_get_config_with_override() -> None:mock_config = merge_default_config(PartialMarimoConfig())- user = UserConfigManager()+ user = UserConfigStore()user._load_config = lambda: mock_configmanager = MarimoConfigManager(user,- MarimoConfigReaderWithOverrides(+ OverrideConfigReader({"runtime": {"on_cell_change": "autorun",@@ -478,9 +485,7 @@ def test_explicit_dotenv_resolves_in_the_home_directory())- config = ScriptConfigManager(str(notebook_path)).get_config(- hide_secrets=False- )+ config = ScriptConfigReader(str(notebook_path)).read()assert config["runtime"]["dotenv"] == [str(home / ".env")]@@ -500,7 +505,7 @@ def test_directory_workspace_dotenv_anchors_on_the_notebook(notebook_path.write_text("import marimo as mo")workspace = get_default_config_manager(current_path=str(repo))- session = workspace.with_partial(ScriptConfigManager(str(notebook_path)))+ session = workspace.with_partial(ScriptConfigReader(str(notebook_path)))config = session.get_config(hide_secrets=False)assert config["runtime"]["dotenv"] == [str(sub / ".env")]assert "runtime" not in session.get_config_overrides(hide_secrets=False)@@ -518,7 +523,7 @@ def test_directory_workspace_dotenv_keeps_the_pyproject_root(notebook_path.write_text("import marimo as mo")workspace = get_default_config_manager(current_path=str(repo))- session = workspace.with_partial(ScriptConfigManager(str(notebook_path)))+ session = workspace.with_partial(ScriptConfigReader(str(notebook_path)))config = session.get_config(hide_secrets=False)assert config["runtime"]["dotenv"] == [str(repo / ".env")]@@ -532,7 +537,7 @@ def test_directory_workspace_dotenv_falls_back_to_the_workspace_root(repo.mkdir()workspace = get_default_config_manager(current_path=str(repo))- session = workspace.with_partial(ScriptConfigManager(None))+ session = workspace.with_partial(ScriptConfigReader(None))config = session.get_config(hide_secrets=False)assert config["runtime"]["dotenv"] == [str(repo / ".env")]@@ -754,7 +759,7 @@ def test_project_config_manager_with_script_metadata(tmp_path: Path) -> None:"""pyproject_path.write_text(textwrap.dedent(pyproject_content))- # Initialize ProjectConfigManager with the notebook path+ # Initialize PyprojectConfigReader with the notebook pathmanager = get_default_config_manager(current_path=str(notebook_path))config = manager.get_config_overrides(hide_secrets=False)@@ -776,13 +781,13 @@ def test_script_config_manager_empty_file(tmp_path: Path) -> None:notebook_path = tmp_path / "notebook.py"notebook_path.write_text("import marimo as mo")- manager = ScriptConfigManager(str(notebook_path))- assert manager.get_config() == {}+ manager = ScriptConfigReader(str(notebook_path))+ assert manager.read() == {}def test_script_config_manager_no_file() -> None:- manager = ScriptConfigManager(None)- assert manager.get_config() == {}+ manager = ScriptConfigReader(None)+ assert manager.read() == {}def test_script_config_manager_with_metadata(tmp_path: Path) -> None:@@ -798,8 +803,8 @@ def test_script_config_manager_with_metadata(tmp_path: Path) -> None:"""notebook_path.write_text(textwrap.dedent(notebook_content))- manager = ScriptConfigManager(str(notebook_path))- assert manager.get_config() == {+ manager = ScriptConfigReader(str(notebook_path))+ assert manager.read() == {"formatting": {"line_length": 79},"save": {"autosave_delay": 1000},}@@ -826,9 +831,7 @@ def test_script_config_manager_dotenv_anchors_on_project('''notebook_path.write_text(textwrap.dedent(notebook_content))- config = ScriptConfigManager(str(notebook_path)).get_config(- hide_secrets=False- )+ config = ScriptConfigReader(str(notebook_path)).read()assert config["runtime"]["dotenv"] == [str(project / ".env"),@@ -851,9 +854,7 @@ def test_script_config_manager_dotenv_anchors_on_standalone_notebook("""notebook_path.write_text(textwrap.dedent(notebook_content))- config = ScriptConfigManager(str(notebook_path)).get_config(- hide_secrets=False- )+ config = ScriptConfigReader(str(notebook_path)).read()assert config["runtime"]["dotenv"] == [str(notebook_dir / ".env"),@@ -872,8 +873,8 @@ def test_script_config_manager_ignores_file_browser(tmp_path: Path) -> None:"""notebook_path.write_text(textwrap.dedent(notebook_content))- manager = ScriptConfigManager(str(notebook_path))- assert manager.get_config() == {}+ manager = ScriptConfigReader(str(notebook_path))+ assert manager.read() == {}def test_script_config_manager_invalid_toml(tmp_path: Path) -> None:@@ -885,8 +886,8 @@ def test_script_config_manager_invalid_toml(tmp_path: Path) -> None:"""notebook_path.write_text(textwrap.dedent(notebook_content))- manager = ScriptConfigManager(str(notebook_path))- assert manager.get_config() == {}+ manager = ScriptConfigReader(str(notebook_path))+ assert manager.read() == {}def test_script_config_manager_no_marimo_section(tmp_path: Path) -> None:@@ -899,8 +900,8 @@ def test_script_config_manager_no_marimo_section(tmp_path: Path) -> None:"""notebook_path.write_text(textwrap.dedent(notebook_content))- manager = ScriptConfigManager(str(notebook_path))- assert manager.get_config() == {}+ manager = ScriptConfigReader(str(notebook_path))+ assert manager.read() == {}def test_script_config_manager_sanitizes_auto_instantiate(@@ -922,7 +923,7 @@ def test_script_config_manager_sanitizes_auto_instantiate("""notebook_path.write_text(textwrap.dedent(notebook_content))- manager = ScriptConfigManager(str(notebook_path))+ manager = ScriptConfigReader(str(notebook_path))with caplog.at_level("WARNING"):from marimo import _loggers@@ -930,7 +931,7 @@ def test_script_config_manager_sanitizes_auto_instantiate(old_propagate = logger.propagatetry:logger.propagate = True- config = manager.get_config()+ config = manager.read()finally:logger.propagate = old_propagate@@ -959,7 +960,7 @@ def test_script_config_manager_sanitizes_isolate_apps("""notebook_path.write_text(textwrap.dedent(notebook_content))- config = ScriptConfigManager(str(notebook_path)).get_config()+ config = ScriptConfigReader(str(notebook_path)).read()assert "isolate_apps" not in config.get("experimental", {})assert config.get("experimental") == {"markdown": True}@@ -981,7 +982,7 @@ def test_script_config_manager_sanitizes_custom_css("""notebook_path.write_text(textwrap.dedent(notebook_content))- config = ScriptConfigManager(str(notebook_path)).get_config()+ config = ScriptConfigReader(str(notebook_path)).read()assert "custom_css" not in config.get("display", {})assert config.get("display") == {"theme": "dark"}@@ -1015,7 +1016,7 @@ def test_script_config_manager_drops_credential_affecting_sections("""notebook_path.write_text(textwrap.dedent(notebook_content))- config = ScriptConfigManager(str(notebook_path)).get_config()+ config = ScriptConfigReader(str(notebook_path)).read()assert "ai" not in configassert "mcp" not in config@@ -1042,13 +1043,13 @@ def test_script_config_manager_ai_base_url_does_not_override("""notebook_path.write_text(textwrap.dedent(notebook_content))- config = ScriptConfigManager(str(notebook_path)).get_config()+ config = ScriptConfigReader(str(notebook_path)).read()assert "ai" not in configassert config == {}def test_marimo_config_reader_properties() -> None:- """Test the convenience properties on MarimoConfigReader"""+ """Test the convenience properties on MarimoConfigManager"""manager = get_default_config_manager(current_path=None)assert manager.default_width is not None@@ -1074,7 +1075,7 @@ def test_project_config_manager_resolve_paths(tmp_path: Path) -> None:(tmp_path / ".env").touch()(tmp_path / "config" / ".env").touch()- # Initialize ProjectConfigManager+ # Initialize PyprojectConfigReadermanager = get_default_config_manager(current_path=str(pyproject_path))config = manager.get_config(hide_secrets=False)@@ -1103,7 +1104,7 @@ def test_project_config_manager_resolve_invalid_paths(tmp_path: Path) -> None:"""pyproject_path.write_text(textwrap.dedent(pyproject_content))- # Initialize ProjectConfigManager+ # Initialize PyprojectConfigReadermanager = get_default_config_manager(current_path=str(pyproject_path))config = manager.get_config(hide_secrets=False)@@ -1121,7 +1122,7 @@ def test_project_config_manager_resolve_missing_paths(tmp_path: Path) -> None:"""pyproject_path.write_text(textwrap.dedent(pyproject_content))- # Initialize ProjectConfigManager+ # Initialize PyprojectConfigReadermanager = get_default_config_manager(current_path=str(pyproject_path))config = manager.get_config(hide_secrets=False)@@ -1140,7 +1141,7 @@ def test_project_config_manager_resolve_custom_css(tmp_path: Path) -> None:"""pyproject_path.write_text(textwrap.dedent(pyproject_content))- # Initialize ProjectConfigManager+ # Initialize PyprojectConfigReadermanager = get_default_config_manager(current_path=str(pyproject_path))config = manager.get_config(hide_secrets=False)@@ -1184,7 +1185,7 @@ def test_project_config_manager_skips_unresolvable_css_home_directory(theme = "dark""""))- manager = ProjectConfigManager(str(pyproject_path))+ manager = PyprojectConfigReader(str(pyproject_path))with patch("pathlib.Path.expanduser",side_effect=[@@ -1192,7 +1193,7 @@ def test_project_config_manager_skips_unresolvable_css_home_directory(tmp_path / "styles.css",],):- config = manager.get_config(hide_secrets=False)+ config = manager.read()assert config["display"] == {"custom_css": [str(tmp_path / "styles.css")],@@ -1211,8 +1212,8 @@ def test_project_config_manager_resolve_invalid_custom_css("""pyproject_path.write_text(textwrap.dedent(pyproject_content))- # Initialize ProjectConfigManager- # Initialize ProjectConfigManager+ # Initialize PyprojectConfigReader+ # Initialize PyprojectConfigReadermanager = get_default_config_manager(current_path=str(pyproject_path))config = manager.get_config(hide_secrets=False)@@ -1223,12 +1224,12 @@ def test_project_config_manager_resolve_invalid_custom_css(def test_env_config_manager_auto_instantiate_true(monkeypatch: pytest.MonkeyPatch,) -> None:- """Test that EnvConfigManager correctly loads auto_instantiate from env"""+ """Test that EnvConfigReader correctly loads auto_instantiate from env"""monkeypatch.setenv("_MARIMO_CONFIG_OVERLOAD_RUNTIME_AUTO_INSTANTIATE", "true")- manager = EnvConfigManager()- config = manager.get_config(hide_secrets=False)+ manager = EnvConfigReader()+ config = manager.read()assert config == {"runtime": {"auto_instantiate": True}}@@ -1246,15 +1247,15 @@ def test_env_config_manager_boolean_case_insensitive(monkeypatch.setenv("_MARIMO_CONFIG_OVERLOAD_RUNTIME_AUTO_INSTANTIATE", env_value)- manager = EnvConfigManager()- config = manager.get_config(hide_secrets=False)+ manager = EnvConfigReader()+ config = manager.read()assert config["runtime"]["auto_instantiate"] is expecteddef test_env_config_manager_no_env_vars() -> None:"""Test that missing env vars return empty config"""- manager = EnvConfigManager()- config = manager.get_config(hide_secrets=False)+ manager = EnvConfigReader()+ config = manager.read()assert config == {}@@ -1264,8 +1265,8 @@ def test_env_config_manager_server_transport() -> None:"""MARIMO_SERVER_TRANSPORT selects the kernel-connection transport"""monkeypatch.setenv("MARIMO_SERVER_TRANSPORT", transport)- manager = EnvConfigManager()- config = manager.get_config(hide_secrets=False)+ manager = EnvConfigReader()+ config = manager.read()assert config == {"server": {"transport": transport}}@@ -1274,8 +1275,8 @@ def test_env_config_manager_server_transport_invalid() -> None:"""Invalid MARIMO_SERVER_TRANSPORT values are ignored with a warning"""monkeypatch.setenv("MARIMO_SERVER_TRANSPORT", "carrier-pigeon")- manager = EnvConfigManager()- config = manager.get_config(hide_secrets=False)+ manager = EnvConfigReader()+ config = manager.read()assert config == {}@@ -1292,7 +1293,7 @@ def test_restrict_sharing_clamps_config_overrides("""monkeypatch.setattr(GLOBAL_SETTINGS, "RESTRICT_SHARING", True)manager = MarimoConfigManager(- UserConfigManager(), EnvConfigManager(), SecurityConfigManager()+ UserConfigStore(), EnvConfigReader(), SecurityConfigReader())overrides = manager.get_config_overrides(hide_secrets=False)assert overrides["sharing"] == RESTRICTED_SHARING@@ -1303,7 +1304,7 @@ def test_restrict_sharing_overrides_user_config() -> None:"""The restriction wins over a user config that enables sharing."""monkeypatch.setattr(GLOBAL_SETTINGS, "RESTRICT_SHARING", True)- user = UserConfigManager()+ user = UserConfigStore()monkeypatch.setattr(user,"_load_config",@@ -1312,7 +1313,7 @@ def test_restrict_sharing_overrides_user_config(),)manager = MarimoConfigManager(- user, EnvConfigManager(), SecurityConfigManager()+ user, EnvConfigReader(), SecurityConfigReader())assert manager.get_config(hide_secrets=False)["sharing"] == (RESTRICTED_SHARING@@ -1324,13 +1325,13 @@ def test_restrict_sharing_beats_later_override() -> None:"""A later with_overrides() cannot re-enable sharing.- with_overrides() appends its partial after EnvConfigManager, but- MarimoConfigManager keeps the SecurityConfigManager last, so the+ with_overrides() appends its partial after EnvConfigReader, but+ MarimoConfigManager keeps the SecurityConfigReader last, so theenforcement still wins over the later override."""monkeypatch.setattr(GLOBAL_SETTINGS, "RESTRICT_SHARING", True)manager = MarimoConfigManager(- UserConfigManager(), EnvConfigManager(), SecurityConfigManager()+ UserConfigStore(), EnvConfigReader(), SecurityConfigReader()).with_overrides({"sharing": {"wasm": True, "html": True, "molab": True}})assert manager.get_config_overrides(hide_secrets=False)["sharing"] == (RESTRICTED_SHARING@@ -1343,7 +1344,7 @@ def test_restrict_sharing_disabled_keeps_user_config("""With the flag off, an explicit sharing config is left untouched."""monkeypatch.setattr(GLOBAL_SETTINGS, "RESTRICT_SHARING", False)manager = MarimoConfigManager(- UserConfigManager(), EnvConfigManager(), SecurityConfigManager()+ UserConfigStore(), EnvConfigReader(), SecurityConfigReader()).with_overrides({"sharing": {"wasm": True}})assert manager.get_config_overrides(hide_secrets=False)["sharing"] == {"wasm": True@@ -1372,7 +1373,7 @@ def test_script_config_manager_strips_signing_and_verification("""notebook_path.write_text(textwrap.dedent(notebook_content))- config = ScriptConfigManager(str(notebook_path)).get_config()+ config = ScriptConfigReader(str(notebook_path)).read()assert "signing" not in config# NB. the script allowlist (ALLOWED_SCRIPT_CONFIG_TOP_KEYS) drops the whole@@ -1401,7 +1402,7 @@ def test_project_config_manager_strips_signing_and_verification("""pyproject_path.write_text(textwrap.dedent(pyproject_content))- config = ProjectConfigManager(str(pyproject_path)).get_config()+ config = PyprojectConfigReader(str(pyproject_path)).read()assert "signing" not in config# `cache.store` is not a trust anchor, so a project may still choose one;@@ -1426,8 +1427,8 @@ def test_effective_config_anchors_trust_in_user_layer_only()manager = MarimoConfigManager(- UserConfigManager(),- ProjectConfigManager(str(pyproject_path)),+ UserConfigStore(),+ PyprojectConfigReader(str(pyproject_path)),).with_overrides({"signing": {"trusted_signers": {user_fp: "me"}}})signing = manager.get_config(hide_secrets=False).get("signing", {})@@ -1442,7 +1443,7 @@ def test_workspace_marimo_toml_strips_signing_and_verification("""A `.marimo.toml` found by walking up from the cwd is project-origin.It loads as the user layer, so it is the one untrusted layer that reaches- `UserConfigManager`; it must still not anchor trust.+ `UserConfigStore`; it must still not anchor trust."""cfg = tmp_path / ".marimo.toml"cfg.write_text(@@ -1471,7 +1472,9 @@ def test_workspace_marimo_toml_strips_signing_and_verification(lambda _path: False,)- config = UserConfigManager().get_config(hide_secrets=False)+ config = MarimoConfigManager(UserConfigStore()).get_user_config(+ hide_secrets=False+ )assert "signing" not in configassert config.get("cache", {}).get("verification") is None@@ -1507,7 +1510,9 @@ def test_trusted_user_config_location_anchors_trust(lambda _path: True,)- config = UserConfigManager().get_config(hide_secrets=False)+ config = MarimoConfigManager(UserConfigStore()).get_user_config(+ hide_secrets=False+ )assert config["signing"]["trusted_signers"] == {_FAKE_FP: "me"}assert config["cache"]["verification"] == "strict"diff --git a/tests/_config/test_secrets_config.py b/tests/_config/test_secrets_config.pyindex 581a0f13e6..386cf58fe2 100644--- a/tests/_config/test_secrets_config.py+++ b/tests/_config/test_secrets_config.py@@ -3,7 +3,7 @@ from __future__ import annotationsfrom marimo._config.config import PartialMarimoConfigfrom marimo._config.secrets import (SECRET_PLACEHOLDER,- mask_secrets,+ redact_secrets,remove_secret_placeholders,)@@ -38,7 +38,7 @@ def test_mask_secrets() -> None:== "bedrock_secret_access_key")- new_config = mask_secrets(config)+ new_config = redact_secrets(config)assert new_config["ai"]["open_ai"]["api_key"] == SECRET_PLACEHOLDERassert new_config["ai"]["anthropic"]["api_key"] == SECRET_PLACEHOLDERassert new_config["ai"]["google"]["api_key"] == SECRET_PLACEHOLDER@@ -72,7 +72,7 @@ def test_mask_secrets_list() -> None:ai={"open_ai": [{"api_key": "super_secret"}]},)assert config["ai"]["open_ai"][0]["api_key"] == "super_secret"- new_config = mask_secrets(config)+ new_config = redact_secrets(config)assert new_config["ai"]["open_ai"][0]["api_key"] == SECRET_PLACEHOLDER# Ensure the original config is not modified@@ -93,7 +93,7 @@ def test_mask_secrets_empty() -> None:)assert config["ai"]["open_ai"]["model"] == "davinci"- new_config = mask_secrets(config)+ new_config = redact_secrets(config)assert new_config["ai"]["open_ai"]["model"] == "davinci"# Not added until the key is presentassert "api_key" not in new_config["ai"]["open_ai"]@@ -108,7 +108,7 @@ def test_mask_secrets_empty() -> None:config["ai"]["google"]["api_key"] = ""config["ai"]["anthropic"]["api_key"] = ""config["ai"]["openrouter"]["api_key"] = ""- new_config = mask_secrets(config)+ new_config = redact_secrets(config)assert new_config["ai"]["open_ai"]["api_key"] == ""assert new_config["ai"]["google"]["api_key"] == ""assert new_config["ai"]["anthropic"]["api_key"] == ""@@ -121,9 +121,9 @@ def test_mask_secrets_empty() -> None:def test_mask_secrets_non_dict_values() -> None:- """mask_secrets must not crash when a secret path hits a non-dict value.+ """redact_secrets must not crash when a secret path hits a non-dict value.- A malformed/partial config can place a non-dict where mask_secrets expects+ A malformed/partial config can place a non-dict where redact_secrets expectsto recurse into a dict. `bedrock=None` previously raised TypeError and`custom_providers="oops"` raised AttributeError; valid providers must stillbe masked.@@ -135,7 +135,7 @@ def test_mask_secrets_non_dict_values() -> None:"custom_providers": "oops",},)- new_config = mask_secrets(config)+ new_config = redact_secrets(config)assert new_config["ai"]["open_ai"]["api_key"] == SECRET_PLACEHOLDERassert new_config["ai"]["bedrock"] is Noneassert new_config["ai"]["custom_providers"] == "oops"@@ -198,7 +198,7 @@ def test_mask_secrets_custom_providers() -> None:)# Mask secrets- new_config = mask_secrets(config)+ new_config = redact_secrets(config)# Verify api_keys are maskedassert (@@ -282,7 +282,7 @@ def test_mask_secrets_signing_private_key_path() -> None:"trusted_signers": {"SHA256:abc": "alice"},},)- masked = mask_secrets(config)+ masked = redact_secrets(config)assert masked["signing"]["private_key_path"] == SECRET_PLACEHOLDER# trusted_signers are public fingerprints — not masked.assert masked["signing"]["trusted_signers"] == {"SHA256:abc": "alice"}diff --git a/tests/_lint/test_lint_config_integration.py b/tests/_lint/test_lint_config_integration.pyindex c0c0229a06..a448267d29 100644--- a/tests/_lint/test_lint_config_integration.py+++ b/tests/_lint/test_lint_config_integration.py@@ -72,13 +72,13 @@ class TestPep723LintConfig:def test_empty_cell_ignored_via_pep723_lint_config(self):"""MF004 is suppressed when the notebook's PEP 723 metadata ignores it."""- from marimo._config.manager import ScriptConfigManager+ from marimo._config.manager import ScriptConfigReadernotebook, _ = self._read_and_parse()# Read lint config from the notebook's PEP 723 metadata- script_mgr = ScriptConfigManager(self.FILE)- config = script_mgr.get_config(hide_secrets=False)+ script_mgr = ScriptConfigReader(self.FILE)+ config = script_mgr.read()lint_config = config.get("lint")assert lint_config is not None, ("Expected [tool.marimo.lint] in metadata"diff --git a/tests/_save/loaders/test_pickle_untrusted_store.py b/tests/_save/loaders/test_pickle_untrusted_store.pyindex 7c28b98860..d2fdc81f4b 100644--- a/tests/_save/loaders/test_pickle_untrusted_store.py+++ b/tests/_save/loaders/test_pickle_untrusted_store.py@@ -65,7 +65,7 @@ def test_workspace_marimo_toml_store_never_reaches_the_loader(the config layer is what keeps it away from an unverified `pickle.loads`;without that, this store would be treated as operator-chosen."""- from marimo._config.manager import UserConfigManager+ from marimo._config.manager import MarimoConfigManager, UserConfigStorefrom marimo._save.stores import cache_store_is_untrusted, get_storeworkspace_config = tmp_path / ".marimo.toml"@@ -82,7 +82,9 @@ def test_workspace_marimo_toml_store_never_reaches_the_loader()# Stripped at the config layer, so nothing downstream has to identify it.- config = UserConfigManager().get_config(hide_secrets=False)+ config = MarimoConfigManager(UserConfigStore()).get_user_config(+ hide_secrets=False+ )assert config.get("cache", {}).get("store") is None# Note it is *not* reachable as an "untrusted override" either, because thediff --git a/tests/_server/api/endpoints/test_file_explorer.py b/tests/_server/api/endpoints/test_file_explorer.pyindex ed4f183336..c3564ce0b6 100644--- a/tests/_server/api/endpoints/test_file_explorer.py+++ b/tests/_server/api/endpoints/test_file_explorer.py@@ -19,7 +19,7 @@ if TYPE_CHECKING:from starlette.testclient import TestClientfrom marimo._config.config import PartialMarimoConfig- from marimo._config.manager import UserConfigManager+ from marimo._config.manager import UserConfigStoreHEADERS = {**token_header("fake-token"),@@ -678,7 +678,7 @@ def test_download_requires_auth(client: TestClient) -> None:def test_download_disabled_by_config(- client: TestClient, user_config_manager: UserConfigManager+ client: TestClient, user_config_manager: UserConfigStore) -> None:user_config_manager.save_config(cast(diff --git a/tests/_server/api/endpoints/test_resume_session.py b/tests/_server/api/endpoints/test_resume_session.pyindex 7ed0367a44..354c9aa812 100644--- a/tests/_server/api/endpoints/test_resume_session.py+++ b/tests/_server/api/endpoints/test_resume_session.py@@ -9,7 +9,7 @@ from typing import TYPE_CHECKINGimport pytest-from marimo._config.manager import UserConfigManager+from marimo._config.manager import MarimoConfigManagerfrom marimo._messaging.notification import (CellNotification,EnvironmentOperation,@@ -369,7 +369,7 @@ def test_resume_session_after_file_change(client: TestClient) -> None:@contextmanager-def without_autorun_on_save(config: UserConfigManager):+def without_autorun_on_save(config: MarimoConfigManager):prev_config = config.get_config()try:config.save_config({"runtime": {"watcher_on_save": "lazy"}})diff --git a/tests/_server/api/endpoints/test_ws.py b/tests/_server/api/endpoints/test_ws.pyindex e09145b9a8..c508d56c96 100644--- a/tests/_server/api/endpoints/test_ws.py+++ b/tests/_server/api/endpoints/test_ws.py@@ -11,7 +11,7 @@ import pytestfrom starlette.websockets import WebSocketDisconnect, WebSocketStatefrom marimo._config.config import ExperimentalConfig-from marimo._config.manager import UserConfigManager+from marimo._config.manager import MarimoConfigManagerfrom marimo._messaging.notification import (EnvironmentOperationNotification,KernelReadyNotification,@@ -509,7 +509,7 @@ def flush_messages(@contextmanager-def rtc_enabled(config: UserConfigManager):+def rtc_enabled(config: MarimoConfigManager):prev_config = config.get_config()try:experimental_config = ExperimentalConfig(rtc_v2=True)diff --git a/tests/_server/api/endpoints/test_ws_rtc.py b/tests/_server/api/endpoints/test_ws_rtc.pyindex 4d4cc72025..73b4796e1f 100644--- a/tests/_server/api/endpoints/test_ws_rtc.py+++ b/tests/_server/api/endpoints/test_ws_rtc.py@@ -7,7 +7,7 @@ from typing import TYPE_CHECKINGimport pytestfrom starlette.websockets import WebSocketDisconnect-from marimo._config.manager import UserConfigManager+from marimo._config.manager import MarimoConfigManagerfrom marimo._server.api.endpoints.ws_endpoint import DOC_MANAGERfrom tests._server.api.endpoints.ws_helpers import (assert_kernel_ready_response,@@ -38,7 +38,7 @@ async def setup_loro_docs() -> AsyncGenerator[None, None]:@contextmanager-def rtc_enabled(config: UserConfigManager):+def rtc_enabled(config: MarimoConfigManager):prev_config = config.get_config()try:config.save_config({"experimental": {"rtc_v2": True}})diff --git a/tests/_server/api/test_auth.py b/tests/_server/api/test_auth.pyindex bc5c81639f..668a05f944 100644--- a/tests/_server/api/test_auth.py+++ b/tests/_server/api/test_auth.py@@ -12,7 +12,7 @@ from starlette.authentication import SimpleUserfrom starlette.datastructures import Headers, QueryParamsfrom starlette.requests import HTTPConnection-from marimo._config.manager import MarimoConfigManager, UserConfigManager+from marimo._config.manager import MarimoConfigManager, UserConfigStorefrom marimo._server.api.auth import (CookieSession,CustomAuthenticationMiddleware,@@ -109,7 +109,7 @@ def app() -> Starlette:headless=False,quiet=False,session_manager=get_mock_session_manager(),- config_manager=MarimoConfigManager(UserConfigManager()),+ config_manager=MarimoConfigManager(UserConfigStore()),remote_url=None,mcp_server_enabled=False,skew_protection=False,diff --git a/tests/_server/api/test_middleware.py b/tests/_server/api/test_middleware.pyindex 5526f9234b..6467f87b81 100644--- a/tests/_server/api/test_middleware.py+++ b/tests/_server/api/test_middleware.py@@ -23,7 +23,7 @@ from starlette.testclient import TestClientfrom starlette.websockets import WebSocket, WebSocketDisconnectfrom uvicorn import Config, Server-from marimo._config.manager import MarimoConfigManager, UserConfigManager+from marimo._config.manager import MarimoConfigManager, UserConfigStorefrom marimo._server._pylsp import create_serverfrom marimo._server.api.auth import TOKEN_QUERY_PARAMfrom marimo._server.api.middleware import (@@ -66,7 +66,7 @@ def init_state(headless=False,quiet=False,session_manager=session_manager,- config_manager=MarimoConfigManager(UserConfigManager()),+ config_manager=MarimoConfigManager(UserConfigStore()),remote_url=None,mcp_server_enabled=False,skew_protection=skew_protection,diff --git a/tests/_server/conftest.py b/tests/_server/conftest.pyindex 24c977e3bf..d71316da6f 100644--- a/tests/_server/conftest.py+++ b/tests/_server/conftest.py@@ -13,7 +13,7 @@ import pytestimport uvicornfrom starlette.testclient import TestClient-from marimo._config.manager import MarimoConfigManager, UserConfigManager+from marimo._config.manager import MarimoConfigManager, UserConfigStorefrom marimo._config.utils import CONFIG_FILENAMEfrom marimo._server.api.deps import AppStatefrom marimo._server.config import StarletteServerStateInit@@ -101,12 +101,12 @@ def client_with_lifespans() -> Generator[TestClient, None, None]:@pytest.fixture-def user_config_manager() -> Iterator[UserConfigManager]:+def user_config_manager() -> Iterator[UserConfigStore]:tmp = TemporaryDirectory()config_path = Path(tmp.name) / CONFIG_FILENAMEconfig_path.write_text("")- class TestUserConfigManager(UserConfigManager):+ class TestUserConfigManager(UserConfigStore):def __init__(self) -> None:super().__init__()@@ -119,7 +119,7 @@ def user_config_manager() -> Iterator[UserConfigManager]:@pytest.fixture-def client(user_config_manager: UserConfigManager) -> Iterator[TestClient]:+def client(user_config_manager: UserConfigStore) -> Iterator[TestClient]:main = sys.modules["__main__"]# Create fresh app for this test to avoid shared state issues@@ -153,7 +153,7 @@ def client(user_config_manager: UserConfigManager) -> Iterator[TestClient]:sys.modules["__main__"] = main-def get_session_config_manager(client: TestClient) -> UserConfigManager:+def get_session_config_manager(client: TestClient) -> MarimoConfigManager:"""Assumes only one active session."""sessions = list(AppState.from_app(client.app).session_manager.sessions.values()@@ -162,5 +162,5 @@ def get_session_config_manager(client: TestClient) -> UserConfigManager:return sessions[0].config_manager # type: ignore-def get_user_config_manager(client: TestClient) -> UserConfigManager:+def get_user_config_manager(client: TestClient) -> MarimoConfigManager:return client.app.state.config_manager # type: ignorediff --git a/tests/_server/mocks.py b/tests/_server/mocks.pyindex 5d6659f6d1..2f5f5d946f 100644--- a/tests/_server/mocks.py+++ b/tests/_server/mocks.py@@ -8,7 +8,7 @@ from typing import TYPE_CHECKING, Any, castfrom marimo._config.manager import (MarimoConfigManager,- UserConfigManager,+ UserConfigStore,get_default_config_manager,)from marimo._server.config import StarletteServerStateInit@@ -45,7 +45,7 @@ def get_starlette_server_state_init(headless=False,quiet=False,session_manager=session_manager or get_mock_session_manager(),- config_manager=MarimoConfigManager(UserConfigManager()),+ config_manager=MarimoConfigManager(UserConfigStore()),remote_url=None,mcp_server_enabled=False,skew_protection=False,diff --git a/tests/_server/test_lsp.py b/tests/_server/test_lsp.pyindex ae6a4c219e..1344ceb6c9 100644--- a/tests/_server/test_lsp.py+++ b/tests/_server/test_lsp.py@@ -1,7 +1,7 @@from __future__ import annotationsimport signal-from typing import TYPE_CHECKING, Literal, cast+from typing import TYPE_CHECKING, Literalfrom unittest import mockimport pytest@@ -13,8 +13,8 @@ from marimo._config.config import (merge_default_config,)from marimo._config.manager import (- MarimoConfigReader,- MarimoConfigReaderWithOverrides,+ MarimoConfigManager,+ get_default_config_manager,)from marimo._loggers import get_log_directoryfrom marimo._messaging.notification import AlertNotification@@ -409,16 +409,13 @@ def test_copilot_server_node_version_validation():def test_composite_server():def as_reader(completion_config: CompletionConfig, config: LanguageServersConfig- ) -> MarimoConfigReader:- return cast(- MarimoConfigReader,- MarimoConfigReaderWithOverrides(- {- "completion": completion_config,- "language_servers": config,- "experimental": {"lsp": True},- },- ),+ ) -> MarimoConfigManager:+ return get_default_config_manager(current_path=None).with_overrides(+ {+ "completion": completion_config,+ "language_servers": config,+ "experimental": {"lsp": True},+ })with mock.patch("marimo._server.lsp.DependencyManager") as mock_dm: