Commit Graph

3 Commits

Author SHA1 Message Date
kshitijk4poor
e39618f448 refactor(config): one public version helper pair in config_backend
Review of the rebased stack found the same "version, or None when the
config is absent" shape written out at three call sites
(`config_version(p) if config_exists(p) else None`), a private
try/except copy of it in profiles_cache, and the gateway importing the
TUI's private `_version_token` from tui_gateway.methods_config.

- config_backend gains `config_version_or_none()` (one backend call, no
  exists-then-stat race) and `version_token()`, moved from
  tui_gateway/methods_config.py unchanged.
- tui_gateway (methods_config, server), the classic CLI config watcher,
  gateway/session_config and the profile roster cache use them;
  profiles_cache drops its private copy.

No behaviour change: same version tuples, same numeric token.
2026-10-25 18:54:09 -07:00
kshitijk4poor
adebe1f8be fix(config): gate the readers main added since the rebase; adopt main's lint rules
Rebasing onto current main brought in direct config.yaml readers that the
seam's reader gate (scripts/check_config_yaml_readers.py) now rejects:

- gateway/session_config.py: the session `config.get mtime` getter uses
  config_exists/config_version + the TUI's _version_token, like
  tui_gateway/methods_config.py already does.
- hermes_cli/profiles.py: _strip_multiplex_flag checks config_exists.
- hermes_cli/config_backups.py: the byte comparison sits inside the
  supports_file_tooling()-gated block; marked like its siblings there.
- hermes_cli/update_receipt.py: _bare_collection_enabled runs in the bare
  bootstrap interpreter with no config stack; presence stat marked.

Main also turned on UP006/RUF100/B009 since the branch base: builtin
generics in the seam's new modules, stale noqa comments dropped, and the
newly unused typing imports removed.
2026-10-25 18:54:09 -07:00
kshitijk4poor
bf90544702 fix(config): address review on the config backend seam
- get_config_backend(): a shell HERMES_CONFIG_BACKEND that the launch home's .env (or managed
  .env) overrides no longer refuses at import time. hermes_cli.config reads config before
  load_hermes_dotenv() runs, so the selector applies those layers in the same order before refusing.
- _route() returns (ConfigBackend, home) for every path: explicit non-home files are served by
  _ExplicitFile, a FileBackend bound to that path, so the helpers call one interface instead of
  branching on an is_layer flag.
- config.get mtime: derived from the backend's opaque version (file backend unchanged: seconds
  from st_mtime_ns; other versions: a stable non-zero crc32).
- The profile roster's config-model cache keys on config_version(), not a local stat; the
  cache moves to hermes_cli/profiles_cache.py (keeps profiles.py under its cap).
- check_config_yaml_readers: catches io.open / builtins.open / os.open and path keywords
  (open(file=p)); scripts/check runs it locally as config-readers.
2026-10-25 18:54:09 -07:00