Background terminal commands run `bash -lic` with no env snapshot, so a
~/.profile or distro /etc/profile that resets PATH dropped every parent-only
dir (bare `hermes` / the venv's tools: command not found), while the same
command in the foreground now resolved. spawn_local gains an opt-in
restore_login_path that prepends the SAME _append_dropped_path_entries
prelude the foreground snapshot uses, fed from the spawn env's PATH; the
terminal tool's local background spawn turns it on. The registry's shell
argv shape is unchanged.
The terminal tool's env snapshot is captured by `bash -l`, and Debian's
/etc/profile resets PATH for every login shell, so the snapshot pinned the
reset PATH over the spawn env for every later command. In the Docker image
that dropped /opt/hermes/bin and bare `hermes` exited 127 (#56634).
The snapshot bootstrap now re-appends, in parent order, every spawn-env PATH
dir the login shell dropped (not only Hermes' bin dir: the gateway's pm
runtime dirs and `docker run -e PATH=` additions too). They go after the
login PATH, so a command that resolved before resolves to the same binary
and the user's ~/.profile additions keep precedence.
The image also ships /etc/profile.d/hermes.sh, which re-adds the ENV PATH
dirs for login shells the snapshot never covers: the terminal tool's
background `bash -lic`, `docker exec <c> bash -l` and ssh.
Found on Hermes Cloud staging.
Debian's /etc/profile unconditionally resets PATH for non-root shells
before sourcing /etc/profile.d/*.sh, so the login-shell env snapshot
serialised the reset PATH and dropped the venv dir the process env put
there (#56634) — bare python3/pip then resolved to the system
interpreter.
The previous approach wrapped the command with a save/restore pair,
but the restore landed after the bootstrap's export -p, so the snapshot
kept the reset PATH anyway. Restore now runs between the init-file
prelude and the command, via idempotent per-entry case guards for
_resolve_hermes_bin_dir() + _managed_runtime_path_entries(), so
restored entries survive into the snapshot and reruns stay
duplicate-free. Tests read the PATH back from a real init_session
snapshot instead of asserting on injected markers.
Rebased onto current main (the branch had gone CONFLICTING).
Outside a served profile, browser-harness binds
<home>/.config/browser-harness/runtime/bu-<BU_NAME>.sock. A deep HOME (a
container's profile home $HERMES_HOME/home, a long account home) or a long
session name pushed that past sun_path and every browser_exec died with
"browser-harness: fatal: AF_UNIX path too long". Only served profiles had a
short-dir fallback.
browser_exec now judges the default socket on the call's final BU_NAME and,
when it would overflow, points BH_RUNTIME_DIR at a private 0700 hbh-<hash>
dir (keyed by uid and harness home): the user's runtime dir
($XDG_RUNTIME_DIR, else /run/user/<uid>) first, the short socket temp root
only where none exists (containers, macOS). A socket that already binds keeps
its path and its live daemon; an exported BH_RUNTIME_DIR/BH_TMP_DIR is kept.
The cronjob schema is sent on every API call. Keep `timezone` (the feature)
with a one-line description and leave the catch-up window override
(`grace_minutes`) to the CLI and dashboard, where it is already settable.
The handler still accepts it, so nothing that passes it breaks.
The catch-up window (how late a missed cron occurrence may run instead of being skipped) was
half the job's period, clamped to 120s-2h, for every job. A job can now override it outright:
0-1440 minutes, `0` meaning never catch up.
`grace_minutes` is a real 0, not "unset" — and the obvious write pattern would eat it:
`v in {None, "", False}` (the `workdir` update lambda) and `if value:` both treat `0` as
False in Python. Both doors therefore share `jobs_time.normalize_grace_minutes`, reads test
`is None`, and the renderer formats before testing truthiness.
The override moves the dispatch stamp too: `_classify_dispatch_lateness` and the dispatch
health metric read the same window, so a job the scheduler calls "late" is never reported
overdue by the dashboard.
Refused on `once`/`interval` schedules: the window describes a missed wall clock, and a
duration has none.
Split from the timezone commit so it can be reverted alone.
A job may pin its own IANA timezone; its cron expression is then that zone's wall clock,
independent of the profile's configured timezone. Absent/None inherits the profile, so an
existing jobs.json keeps byte-identical behaviour and needs no migration.
The dispatch path needs the pin as much as the compute does. `compute_next_run()` resolves
the zone as job pin -> profile zone -> base offset, and every site that writes `next_run_at`
now passes it (advance, claim, resume, re-arm, recovery, and the quota/unreachable
planners); one missed site re-fires or skips a slot because the stored instant and the
expression would be read in different zones.
`_evaluate_due_job()` normalizes the stored instant into the JOB's zone, which hands every
downstream cron predicate the job's clock, and a pinned job skips
`_repair_timezone_shifted_cron` outright. That repair exists for jobs that FOLLOW the profile
zone across a zone change: on a pinned job its wall-clock comparison reads a due occurrence
as still-in-the-future and re-anchors past it.
Failing shape this fixes (profile America/Los_Angeles, job 0 9 * * 1-5 pinned to
America/New_York, scanned at 09:00 New York): `get_due_jobs()` returned [] and the job was
re-anchored to the next day, i.e. job zones east of the profile zone silently never fired.
The regression test drives the public store API and asserts both the fire and the absence of
the repair, and is proven red on main ([] and a rewritten instant).
Knobs live in the new sibling `cron/jobs_time.py`; `cron/jobs.py` stays over the file-lines
ratchet and only gained the call-site plumbing.
A scheduled heartbeat muted interim messages by rewriting the turn's display
settings, and the agent build read that muted value to freeze the session's
delegation mode. Heartbeats run under the user's session key, so on a cold
agent cache a heartbeat built (and cached, and pinned) an inline agent for an
interim-on chat, and the user's later turns ran inline. The heartbeat rewrite
no longer touches interim: TurnRunner already drops interim messages for a
heartbeat turn, and the TurnContext keeps the chat's configured value, which
is what a fresh agent's delegation.gateway_mode reads.
A fresh agent restored its session's tools[] pin (schema bytes) but kept the
build-time inline flag, so the next rebuild from fresh definitions
(compaction boundary, /reload-mcp, Bot Chat refresh) re-derived the other
variant and flipped the chat mid-conversation. restore_agent_tool_prefix now
re-freezes the flag from the restored delegate_task, making the pin
authoritative.
Docs: inline turns past the notify interval still get the long-running
notice (display.long_running_notifications); the stability sentence now
names compaction, /reload-mcp and heartbeats, and the post-update exception;
a deferred delegate_task (tool_search.defer) stays background.
Tests: heartbeat-first turn with an agent cache (interim on stays
background, control, interim off stays inline), a composed cell with agent
cache + real SessionDB pin + heartbeat + restart, and pin restore followed by
a compaction or /reload-mcp refresh in both directions.
On a messaging chat with display.interim_assistant_messages off, a top-level
delegate_task still produced two messages: a "checks are running, I don't have
the findings yet" reply and, later, the real answer. Top-level model
delegations always run in the background (ea8a8b4af8), and the tool text tells
the model to "give a one-line status and END YOUR TURN" (c89f3b8800). That
status is the turn's final answer, not interim text, so no display setting
held it back.
New key delegation.gateway_mode: auto | inline | background (alias async).
auto (default) joins the children inside the turn on a messaging chat whose
resolved interim setting is off (global, display.platforms.<p> override or
platform default). The parent waits in the tool call, gets the results there
and sends one answer. API, local and webhook surfaces keep the background
path under auto. Chats with interim messages on are unchanged: same schema
bytes, same async dispatch.
How it works:
- The gateway resolves the mode from the turn's own profile-scoped config
when it builds a session's agent (gateway/session_execution.py), and the
agent's first tool build freezes it (like the one-shot pin).
- An inline session carries the joined delegate_task variant the one-shot
path already uses: "results return in this tool call", no live-control
parameters, no END YOUR TURN.
- Dispatch follows the delegate_task schema the session carries
(session_joins_delegation), so schema and behaviour cannot disagree. The
schema rides the session's tools[] pin: a config change applies from the
next session (/new), as delegation.backend does, and a cache eviction or
restart never flips a running chat.
- Inline children run on the existing synchronous path: attached to the
parent, so /stop and an interrupting follow-up stop them; the per-child
heartbeat keeps the parent's activity fresh for the inactivity watchdog;
the async completion registry is not used. Nested and one-shot delegation
are unchanged.
Refs #95522.
The metadata floor and the guard-on private check scanned every string in
every CDP call, so Input.insertText typing 'http://169.254.169.254/' (or a
LAN URL with the guard on) was refused although typing fetches nothing.
Input.* methods only insert text or dispatch key/mouse events; skip the
URL-literal scan for them.
The cloud-metadata check on raw CDP ran only with the private-address
guard off, and only on a `url` param. With the guard on, an unlisted
method such as Network.loadNetworkResource fetched a metadata host or a
loopback URL from a public page, because only the page URL was checked.
Every CDP call now screens each `url` param and every http(s) literal
in its string params (function bodies, injected scripts, HTML) against
the metadata floor whatever the guard says. With the guard on, unlisted
methods also refuse private literals in their own params.
browser_exec still follows a page's own redirect or fetch to a metadata
address: the floor reads the URLs the agent writes, not the browser's
later traffic. security.md and browser.md now say that instead of
"refused on every route", and point at network-level IMDS blocking.
With the private-URL guard off (local backend, or browser.allow_private_urls on
a cloud/CDP backend) the floor only checked Page.navigate/Target.createTarget, so
Runtime.evaluate("fetch('http://169.254.169.254/...')"), Network.loadNetworkResource
and Fetch.continueRequest reached the metadata endpoint that browser_exec refuses on
every path. The guard-off branch now runs every _METHOD_PARAM_GUARDS probe (and the
url param of any other method) with an is_always_blocked_url-only predicate.
browser_cdp skipped its whole URL guard on a local terminal backend or
with browser.allow_private_urls: true, so Page.navigate and
Target.createTarget could open 169.254.169.254 while browser_exec
refuses it unconditionally (#16234). The metadata check now runs on
those two methods regardless, which is what the security docs state.
process_registry.py and its test file are over the 2,000-line target and may
only shrink: the PTY/pipe Enter choice collapses to one expression and the two
submit_stdin tests move to tests/tools/test_process_registry_submit.py.
submit_stdin appended \n unconditionally, but raw-mode TUIs (claude,
vim, htop) bind Enter to \r — what a real keyboard sends — so submitted
input never registered as Enter in interactive TUI sessions. Send \r
for PTY sessions instead; canonical-mode children are unaffected since
the tty driver's ICRNL maps \r to \n. Same reason tmux send-keys Enter
transmits \r. Non-PTY (pipe) sessions keep \n.
Claude-Session: https://claude.ai/code/session_013LH6C3g6wjMjhSXRauyVCW
The fill events now cross the shadow boundary (composed), so a component tracking its value on the
host sees the password; tab selection finds a form inside an open shadow root; the fill script
collects the stamped controls once instead of walking the page per field.
browser_vault reached pages only through the task's CDP supervisor. Camofox (now a plugin) has no
CDP endpoint, so every fill on a Camofox tab ended with "Could not determine the current page
origin": the username from browser_vault list worked, the password never filled.
ctx.register_browser_page_backend lets a plugin browser carry the vault's origin read, form
inspection and fill script to its own page. Core keeps the secret contract: the exact-origin
pre-check and in-page re-check, the Bot Desktop takeover check, an in-page try/catch around the
secret script, and fixed failure text on that path. Registration follows the login-backend
provenance rule (bundled, or catalog verified/official at its pin) and is refused under
plugins.isolation: host.
Consolidates the core half of #127179 and #135204 (the Camofox halves already shipped in the
official plugin); the in-page wrapper follows #114414.
Co-authored-by: Jonathan Bruce <jonathan.bruce369@gmail.com>
Co-authored-by: clsferguson <cferguson@live.ca>
Co-authored-by: Benjamin PERRY <benjaminperry6@yahoo.fr>
The grep/find fallback can report thousands of unreadable paths; the
merge checked each against a growing list although only three are shown.
Stop collecting at three distinct names while still summing every count.
The multi-root merge rebuilt each root's skipped-path list by regex-parsing
the "Skipped N unreadable path(s)..." sentence and splitting on ", ", so a
skipped directory named "one, two" became two fragments and the merged
count was wrong (3 instead of 2). SearchResult now carries skipped_paths and
skipped_omitted beside the warning; the merge sums those and composes the
one sentence itself. Single-root warning text is unchanged.
A comma/space multi-path search merged per-root results but dropped each
root's skipped-unreadable-path warning (content mode) and overwrote the
traversal warning with its "searched N that exist" note (filename mode),
so a search that skipped mode-000 directories looked complete.
Child warnings are now merged (skipped-path sentences collapse into one
with the summed count; other notes deduplicated; the nothing-matched hint
dropped once any root produced results) and the multi-root note is
appended. The macOS protected-folder note on single-root searches is
appended the same way instead of replacing the existing warning.
_PERMISSION_DENIED_RE made the rg:/grep:/find: prefix optional, so the shell's
own 'bash: /usr/bin/rg: Permission denied' (exit 126 under pipefail) parsed as
an unreadable path and content search returned an empty result with a
'Skipped 1 unreadable path(s): bash: /usr/bin/rg' note. Require the tool
prefix, and report the shell's exec failures (126/127) as a search error.
Once permission errors filled the 64 KiB retention cap, later lines were
dropped unread, so a vanished path or read failure behind them left a
permission-only diagnostic and the search reported partial success.
The drain now keeps the first non-permission line past the cap.
- The native rg runner keeps draining stderr but retains at most 64 KiB
(first line always kept); dropped lines are tallied and still counted in
"Skipped N ... (+N more)". Unreadable-path dedupe uses a set (first-seen
order kept).
- find exit 1 with results now names the first non-permission diagnostic
("Some paths could not be read: ...") instead of reporting a permission
problem; the rg/grep content lane does the same when a non-permission
error sits beside permission skips.
- The unreadable-bound test checks the exact skip count only on a run whose
limit lets traversal finish; the bounded run asserts the budget and the
warning's presence.
On macOS a child that exited but is not yet reaped has no process group:
os.getpgid raises ProcessLookupError. The bounded native rg lane polls,
then kills the group; when rg finished between the two (the bound hit
right at exit), _kill_process_group_posix had no recorded pgid to fall
back on and the search raised. Record pgid and leader start time at
spawn, as LocalEnvironment._run_bash does. Seen on the macOS CI lane.
Drop the generic exit-2 acceptance for target="files": main pins that rg output
with an exit 2 and no permission diagnostic fails closed
(test_rg_partial_output_with_error_exit_fails_closed). Only permission-denied
skips degrade to partial results.
Layered on the salvaged #114655 commits:
- The native rg lane merged stderr into the bounded stdout stream, so 60
permission-denied lines filled a limit=3 page and search_files returned
zero files for a tree that had five. Kept stderr now drains on its own
pipe (the shell lane never piped stderr into `| head` either) and is
prepended to the output for the diagnostics parser.
- The no-rg find lane keeps find's stderr (outside sort/head) so the
warning names the unreadable paths instead of a generic sentence, and a
permission-only exit 1 with no matches is an empty result plus warning;
any other exit-1 failure shows find's first diagnostic.
- rg exit 2 beside real output with a non-permission diagnostic keeps the
output too (rg printed every path it could), with a warning naming the
first error. Same for content search.
- Warning text no longer tells the model to "search the path directly"
(that cannot help with EACCES) or claims the whole scope is unreadable
when nothing matched in the readable part.
Found on Hermes Cloud staging: search_files(target="files") on a data dir
holding a root-owned mode-700 lost+found failed outright.
The find -prune -exec grep lane discarded stderr (2>/dev/null), so find's
"Permission denied" diagnostic never reached the parser and a readable match
beside an unreadable subtree came back warning-free. Keep stderr attached and
recognise find's quoted diagnostic shape in the permission classifier.
The count branch of _parse_search_output computed the partial-result warning but did not pass it to SearchResult. Add count-mode regression tests (partial warning kept, clean count stays warning-free).
rg --files exit 2 (EACCES on any walked path) was treated as an invocation
failure in the file-discovery lane: stderr was discarded (2>/dev/null) and
exit 2 was outside the accepted {0,1,124} set, so one unreadable directory
anywhere under the search root produced the bare error "File search failed
while running ripgrep." with no detail and no results.
- _search_files_rg merges stderr, separates diagnostics from paths by the
"rg: "/"grep: " prefix, and degrades a permission-only exit 2 to partial
results plus a "Skipped N unreadable path(s)" warning, in both orders.
The directory supplement (#54347) still runs on the degraded path.
- Content search keeps the same partial-success contract for rg AND grep:
the unreadable-path matcher accepts grep's "grep: <path>: Permission
denied" as well as ripgrep's "(os error N)" spellings, so the grep
fallback no longer hard-fails on a tree with an unreadable directory.
- Bad regex/glob and other IO errors still fail closed, now with the
diagnostic text; the modified-order failure no longer blames the ripgrep
version the capability gate already accepted.
- The bounded-find fallback treats find exit 1 with a payload as partial
results plus a warning (empty payload still fails closed).
The content digest hashed the provider's raw text, but the cache reads
the file in text mode (CRLF/CR -> LF) with utf-8-sig (BOM dropped), so
a CRLF page never matched and every call re-bought the vendor fetch.
Hash the normalized form on both sides.
The cache body and its final-URL annotation were separate writes, so two fetches of one key
interleaved as A-put, B-put, B-final, A-final left B's body validated against A's destination.
The index entry now records the body's sha256; the final-URL write is compare-and-set on it and
a hit is served only when the body on disk matches the entry it was recorded for.
The keyless Firecrawl path returned the requested URL and dropped metadata.url, so the shared
redirect gate never saw the destination. It now reports metadata.url (sourceURL = requested).
Only Firecrawl re-checked the post-redirect URL against the website blocklist
and SSRF. Keenable (keyed and keyless) reports the redirect target in `url`
with `sourceURL` = requested and never re-checked it, so a redirect into a
blocklisted host was served, and the keyless rescue ring had the same gap.
_dispatch_extract now runs website policy + SSRF on every non-error page a
provider (or the rescue ring) reports under a URL that was not requested,
returning Firecrawl's refusal shape (`blocked_by_policy` for policy, the
private-address error for SSRF). Refused pages are never cached, so a cache
hit can no longer be refused into a paid re-fetch of a page we will not
serve. A policy check that raises refuses (fail closed); the cache-hit
final-URL gate now treats a raising check as a miss instead of propagating.
Firecrawl's provider-local check is kept unchanged.
extract_cache_put skips oversized pages, but the final-URL record still ran
and pointed the OLD entry (a now-blocked page) at the refetch's allowed
target, so later hits checked the wrong URL and served the blocked page.
The put now reports whether it wrote, and the final URL is recorded only
then.
The extract cache gated a hit on the REQUESTED URL only. A redirector page
cached while its target was allowed kept serving the target's content after
the target was added to security.website_blocklist (or turned private), until
the entry expired.
Record the post-redirect URL in the cache index and, on a hit, run the same
website-policy and SSRF checks on it; a refused final URL is a miss, so the live
fetch re-checks the redirect and refuses with blocked_by_policy.
Found on Hermes Cloud staging.
The rescue exists for backend outages. A batch whose URLs all answered 404/410
is the pages' own answer, so re-fetching it through the keyless ring wasted a
request and contradicted _dispatch_extract's docstring. Origin-status errors
(the "HTTP <code> from origin" shape) are now excluded from the whole-batch
trigger; backend failures still trigger it.
An entry carrying an origin HTTP error now keeps the page body (a 404
page can help), but _truncate_results skipped every entry with an error,
so a large 403/500 page entered context whole. Error entries' content
now goes through the same head/tail window and footer.
The direct-API Browser Use route stamped "cloud" from configuration before the harness chose its
browser. With BU_AUTOSPAWN the harness attaches to a local Chrome that is already listening, and
capture_screenshot()/new_tab() then switched the user's visible tab. That route now asks the live
harness daemon (daemon_browser_kind() == "cloud", set only by a BU_BROWSER_ID cloud browser) at each
call; a provider session whose CDP endpoint Hermes resolved keeps activating, every local, connected
or autospawn-fell-back-to-local browser never does.
capture_screenshot() activated a hidden agent tab on every backend, so on
/browser connect, the real-profile browser or a local headed Chrome each
screenshot switched the user's visible tab. Activation now follows the same
cloud flag new_tab uses; the 10 s png deadline and jpeg fallback stay on every
backend. new_tab's activation on cloud no longer raises after the tab exists
when a provider rejects Target.activateTarget.
Chrome draws no compositor frame for a hidden tab, and Browser Use cloud
never answers a png Page.captureScreenshot for one, while the harness
creates its tabs in the background. browser_exec now launches the harness
through a thin launcher that rebinds capture_screenshot() (bring a hidden
tab to the front, png with a 10s deadline, then one jpeg fallback saved
as png) and, on cloud-provider browsers, new_tab() (activate the tab).
The model code still arrives untouched on stdin.
Found on Hermes Cloud staging.
- spawn_local records why a pty=true spawn fell back to pipe mode
(ProcessSession.pty_fallback); the stdin errors name that reason instead
of telling the agent to repeat a pty=true request that already failed.
- A background cron run dispatches with model=None: the run session is the
only source of the notice's model, so a refused fire of a pinned job no
longer prints the pin it never ran.
- Tests wait on the completion queue / wait_until instead of sleep polling,
and spawn in tmp_path.
terminal(background=true) without pty connects stdin to /dev/null, so
`read x; echo $x` exits before any process_manage write and the write
said only "Process has already finished". Name the cause and the pty=true
relaunch there too (same PTY-availability guard).
A background cronjob(action='run') completion rendered "Model: ?" and
"API calls: 0" whatever the job did: _manual_run_completion hard-coded
api_calls 0 and the dispatch only knew the job's model pin (None on the
default model). The runner now reads the fire's run session from
state.db (list_cron_job_runs by execution id, summed over its
compression chain); with no run session the fields are omitted, and the
async-delegation event and renderer omit them instead of printing ?/0.
process_manage write/submit on a local background process spawned
without pty said "non-local backend or stdin closed". The new sibling
tools/process_registry_stdin.py says to relaunch with pty=true, except
where a PTY cannot be had (isolated worker log spawn, PTY library
missing) or the backend is non-local. process_registry.py line count
unchanged.
Found on Hermes Cloud staging.
Review findings on the config_keys seam:
- Discovery: drop the glob scan. config_keys is parsed onto PluginManifest
(plugin.yaml, and extensions.com.nousresearch.hermes in a portable
plugin.json) and read from the loader's own collect_directory_manifests +
entry points + resolve_manifest_winners, so skip rules, precedence and the
project-plugin gate are the loader's.
- Only active plugins count: gate_manifest must load the plugin (disabled wins,
plugins.enabled opt-in, requires_hermes); memory providers count when
memory.provider selects them.
- Bounded: a declared path is at least two segments deep and is ignored when
DEFAULT_CONFIG already defines it; runtime keys are consulted only after the
schema walk refused a key, so a plugin declaring [agent] no longer hides
agent.max_turnz.
- No lru_cache: a plugin installed or enabled in a long-running process counts
on the next config get/set (the lookup runs only for refused keys).
- computer_use.backend (read by the plugins/computer_use selector) and
dashboard.kanban move to a core table with their readers; the selection
sections derive from read_selection's own _SELECTION_NAME_KEYS.
- Tests use fixture plugins (enabled/disabled, hostile [agent], selected memory
provider, portable plugin.json, project opt-in).
`hermes config get browser.cloud_provider` / `browser.use_gateway` warned "not a recognized
config key" although the runtime selects the browser provider from them. The validator only
walks DEFAULT_CONFIG, and provider selections stay unseeded on purpose (a stored key is the
explicit pick), as do core-section keys plugins read.
- tools.tool_backend_helpers.selection_config_keys(): the keys read_selection() honours
(<category>.use_gateway, browser.cloud_provider, stt/tts/image_gen/video_gen provider keys,
web.backend/search_backend/extract_backend).
- plugin.yaml / dashboard manifest.json `config_keys`: a plugin names the core-section paths it
reads; declared for retaindb, byterover, computer_use/cua, kanban dashboard.
- hermes_cli/config_runtime_keys.py consults both before the DEFAULT_CONFIG walk.
Found on Hermes Cloud staging.
HERMES_GATEWAY_EXTERNAL_SUPERVISOR is the only profile pin an
--external-supervisor gateway holds: the agent's own `hermes ...` commands
read it (_under_gateway_supervisor) to skip the sticky active_profile.
Stripping it from tool children sent a default gateway's agent onto another
profile after `hermes profile use work` (#74872 shape), and the auto-started
daemon lost HERMES_SUPERVISED_CHILD's pin the same way.
Both strip points now carry the pin as HERMES_GATEWAY_PROFILE_PIN, which
_under_gateway_supervisor and the dashboard's fixed-identity check read and
is_gateway_supervisor_process / is_supervised_gateway_launch never do, so a
gateway an agent starts still answers unsupervised.
Reported by @kshitijk4poor in the #145930 review.
Every child env the agent builds (terminal tool, background processes,
cron scripts, hermes_subprocess_env helpers, build_subprocess_env with or
without the secret scrub) inherited HERMES_LAUNCHD_LABEL, which the
stderr-timestamp wrapper forwards to the ONE gateway launchd starts
(#120087). A gateway an agent then starts from its terminal read the
parent's label: _detect_supervisor() answered "launchd",
is_gateway_supervisor_process() was true, /restart took the exit-75 route
no supervisor answers, and the drain cap logged and probed the parent's
job. HERMES_GATEWAY_EXTERNAL_SUPERVISOR, which `gateway run
--external-supervisor` stamps into its own environ, leaked the same way,
and so did systemd's NOTIFY_SOCKET / WATCHDOG_USEC / WATCHDOG_PID, which
name the unit's main process only.
Strip those names in the shared child-env guards (_finalize_child_env and
the unscrubbed build_subprocess_env branch). Kept on purpose:
XPC_SERVICE_NAME (launchd's per-process stamp; `hermes update` compares it
to tell it runs inside a job), INVOCATION_ID / JOURNAL_STREAM (systemd
sets them for the whole unit and the gateway-child dispatch reads them),
and the launch markers HERMES_SUPERVISED_CHILD / HERMES_S6_SUPERVISED_CHILD.
Reported by @kshitijk4poor on #144648.
Co-authored-by: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com>