Four writers under get_hermes_home() still created their directory with a raw
mkdir(parents=True). A gateway or plugin process bound to a named profile that
was deleted or renamed meanwhile brought profiles/<name>/ back on its next
write (probed on #158270's head by @xytxg and @BearHuddleston; tracker #155595 U3).
They now go through mkdir_under_hermes_home, the #158270 boundary:
- plugin host extraction cache (cache/plugin_host/model-providers/*.json):
skipped, and the extracted payload is still returned;
- Discord slash-command sync state: the path helper no longer creates the
dir. Reads need none, and the write's atomic_json_write already creates it
through the boundary. A refused write ends in the sync's existing
"Slash command sync failed" warning;
- Google Chat bot-id cache and the router catalog disk mirror: their
existing OSError / Exception handlers turn the refusal into a skip.
Each gets a delete+rename regression that fails on main and on a raw-mkdir
mutant.
Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
61 call sites counted directories up from their own __file__ to find the
install folder. They now call hermes_cli._startup_fast.project_root_str(),
so the layout move changes one line instead of 61.
Kept with a reason in the lint baseline: files that cannot import Hermes
code (bootstrap, update path, pm/) and the sys.path bootstraps left for
part 2b. The baseline drops from 89 to 28 root_from_file sites.
Six existing tests that patched a module __file__ now patch the owner.
Under plugins.isolation: host, profile_call encodes kwargs without callable refs, so the
is_suppressed / explicitly_configured lambdas arrived in the host as non-callable Opaque values
and a hosted provider seeded nothing (while _profile_seeds_pool still disabled generic env
seeding). The seam now passes data: suppressed_sources (frozenset) and explicitly_configured
(bool), computed only for profiles that override the seam.
Shell-exported GH_TOKEN-style names are always stripped from child envs, so a hosted provider
that declares them (env_vars + ambient_credentials) never saw a shell-only token. The plugin host
env now re-adds exactly those names through get_secret under the host home's scope: the launch
home keeps its shell value, a routed home gets only its own .env value, never the launch one.
R4 P2-1 (wire W1). Under plugins.isolation: host, one profile overriding
create_client() made the whole credential-free extraction raise
PluginHostUnsupported, so every profile of that plugin vanished (the
github-copilot plugin lost both copilot and copilot-acp).
The extraction now classifies profile by profile: hostable profiles become
plugin-host proxies as before; a profile that cannot cross the boundary is
reported with its reason, and discovery imports the plugin in-process with
registration restricted to exactly those names (_REGISTRATION_ONLY), logging
one warning per such profile. Hosted siblings stay hosted.
With cwd set to the Hermes home, a relative HERMES_HOME (or plugin dir)
resolved a second time from inside it, so extraction under
plugins.isolation: host failed ("No __init__.py in hh/plugins/...").
Pass absolute paths for cwd, HERMES_HOME and the plugin dir. Reviewer
probe with HERMES_HOME=hh: provider registered again.
The one-shot profile extraction child ran as python -m hermes_cli.plugin_host_child with no
cwd and no safe-path flag, so the directory Hermes was launched from sat ahead of PYTHONPATH
on sys.path and a hermes_cli/ package there ran instead of the Hermes tree's. Spawn it with
-P and cwd=<hermes home>, matching the long-lived plugin host.
The credential-free profile extraction child got HOME but not USERPROFILE.
Windows resolves Path.home() from USERPROFILE only, so the child exited with
"Could not determine home directory" and every user model-provider plugin was
silently dropped under host isolation.
Reported-by: Enough1122
Independent review of the plugin host found eight defects; each is fixed here and
the reproducible ones are covered by two new invariant tests (red on the previous
head, green now).
- Async plugin code: `await ctx.<facade>.<async method>` works (the facade probe
reports coroutine methods and the host returns a coroutine function), and ctx
calls made from coroutines keep the caller's session. The wire origin is now a
ContextVar carried onto host event-loop tasks, and the host's fallback context
starts empty instead of copying whichever caller created the host.
- Memory / context-engine / cron providers survive a host crash: proxies record
the host generation, and a category proxy reloads its plugin into the new host
on next use (bounded by the same restart budget). A proxy from an earlier host
can no longer address a recycled object id.
- Hosted provider objects no longer leak: the host imports a category plugin's
module once and drops objects whose Hermes proxies were collected.
- Every public attribute of a hosted object is read live (class-level defaults
included), and attributes Hermes assigns reach the plugin's object unless they
hold a live handle.
- A user memory provider's config_schema.py runs in the plugin host.
- Dashboard plugin APIs resolve the plugin in the requesting profile (its copy,
its plugins.enabled, its host) and keep repeated headers such as Set-Cookie.
- platform_actions coroutines run on the gateway loop their adapters use.
- Each incoming request gets its own thread (no pool exhaustion under nested
callbacks); a late close from a replaced host no longer triggers a reload; the
model-provider extraction cache is keyed by full path.
plugins.isolation: host imports every non-bundled plugin in a host process started
on demand per profile with only that profile's environment, and hands plugins a
RemotePluginContext; Hermes registers proxies for tools, hooks, commands, skills and
provider objects (subclasses of the ABC it checks). Re-entrant: handlers may call
ctx back into Hermes while Hermes waits on them. Every user-code import path routes
to the host (general, memory/context-engine/cron, model-provider profiles via a
cached credential-free extraction, dashboard APIs via an ASGI bridge) or refuses.
One table names what cannot cross (live gateway objects); the static audit shown
by `hermes plugins validate/show` reads it. A host that dies is restarted with its
plugins (bounded). Default stays in_process: nothing changes unless opted in.
Why: shared-pool deployments must never run one tenant's plugin Python in an
interpreter holding another tenant's data, without plugins becoming tenant-aware.