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>
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.
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.
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.