7 Commits

Author SHA1 Message Date
yoniebans
e09f4b7c47 refactor(gateway): session authority and gateway storage callers through the persistence interface
The gateway's session, authority, delivery and hosted-room modules call the interface operations instead of SessionDB and their own connections. The cron owner fake builds its authority on an interface handle, and the legacy cron run-history cases read the owner's store through a SessionDB of their own. The legacy tests whose cases the backend copies carry (journal mode, profile purge and rekey, owner reset housekeeping) go; the remaining legacy tests of these callers follow the moved names.
2026-11-17 17:51:21 +01:00
unsupportedpastels
b8e986cb2b fix(gateway): pin the payload launcher row and read its profile past -P
The bundled/Docker payload's bin/hermes (scripts/build/launchers.py::
posix_launcher) runs `python -P -c "import os, site, sys; ..." <argv>`.
Two gaps remained after recognising that bootstrap:

- The row matched `import os, site, sys;.*` plus any `from <module>
  import <func>`. The `.*` could span a carrier program's own source
  plus the launcher argv it carries, and the substring check in
  _gateway_command_subcommand accepted `not_hermes_cli.main`,
  `foreign.hermes_cli.main` and `hermes_cli.main_x` as Hermes. The row
  now spells out the emitted statements and accepts only
  `from hermes_cli.main import main`. It maps like the other
  module-spelling rows, so the published launcher's `--run-module`
  switch is not honoured for it.
- profile_flag_value lowercased the whole command line first, so the
  interpreter's `-P` read as `-p -c`. _command_line_belongs_to_profile
  rejected even the default-profile payload gateway, which left
  live_gateway_pid_for_home (dashboard, gateway stop/restart) blind
  after the matcher fix. hermes_cli.gateway's scan filter had the same
  problem. profile_flag_value now reads a recognised bootstrap's Hermes
  argv, and its callers pass the case-preserved command line.

The tests render the real posix_launcher output and cover the
space-joined and list2cmdline forms. They check gateway run/--replace
and -p/--profile, the strict and runtime matchers on gateway restart,
non-gateway subcommands, the -m mapping, foreign entry modules,
carrier programs, profile parsing, and live_gateway_pid_for_home on
default and named homes.

Fixes #127865, #135316
Salvages #127868

Co-authored-by: Kong <8760567+vKongv@users.noreply.github.com>
2026-10-15 12:06:34 +05:30
Yuan Li
7e247c44a6 fix(gateway): recognize bundled launcher bootstrap
(cherry picked from commit 90cb42d443c0e5dcb9befc15060635dd9761e57b)
2026-10-15 12:06:34 +05:30
Maciej Lisiewski
d76cce4f11 ci: apply all automatic linter fixes available 2026-10-08 17:22:54 +02:00
Teknium
f55f8d4e4c fix(gateway): decode the re-entered .cmd launcher directly; keep the base64 form untouched in the test
The exec row rebuilt an `import base64; exec(base64.b64decode(...))` string only to feed it back
through the base64 row; decoding the payload directly is shorter and leaves no line that reads like
the base64+exec payload signature the supply-chain scan (rightly) refuses. The test derives the two
re-entry forms from the existing launcher forms instead of re-spelling the cmd-launcher source.
2026-10-07 04:39:00 -07:00
Teknium
33764c64d3 fix(gateway): a gateway re-entered through a dependency-syncing launcher is a gateway
When a launch through the published -c launcher (POSIX shell or Windows .cmd) syncs dependencies
first, venv_sync.relaunch_command re-execs it as `python -I -c "...; sys.argv = [...]; exec(<launcher
source literal>)"`. _BOOTSTRAPS covered the run_module/run_path re-entries but not this exec branch, so
the gateway it started was invisible to every canonical reader: live_gateway_pid_for_home, the fleet
restart, the stale-survivor sweep and update inventory. The new row matches the launcher in place by its
own anchors (readers normalize the literal escapes, so decoding it cannot work) and recurses into the
base64 row for the .cmd form. Extends the #124318 identity table and its test.
2026-10-07 04:39:00 -07:00
Teknium
f9f8962fbb refactor(gateway): move inline-source argv parsing out of gateway/status.py
gateway/status.py grew past main's size (code-health FILE_LINES). Move the
cohesive `python -c <src>` parsing group -- inline_source_flag_index,
command_line_runs_inline_source, the Hermes bootstrap patterns,
_bootstrap_entry and inline_bootstrap_argv -- verbatim into the new sibling
gateway/status_inline_source.py (no imports of the facade, so no cycle).
status.py imports the three names it uses; the one external caller
(hermes_cli/update_cmd_windows.py) now imports from the sibling. No shim,
no docs named the symbols. Behaviour unchanged.
2026-10-06 06:18:39 -07:00