7066dcd33db845548ab954eb68774b795b5dedbb
58 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e646e432b5 |
fix(plugins): lend a start's launcher to an extraction its env build runs
3adc70d33b moved the child-env builder's import into the host's base context. The first import reads the provider registry, which can run a cold hosted-provider extraction. Outside a lent launcher, that extraction picks its own in the base context, which binds no launch scope for a single-profile TUI or dashboard start. It then ran under the process env's launcher, not the one the start chose from the launch scope. The env build now runs under lending_launcher, as the ambient-credential scan already did. The launch-body extraction test gains the case where the start is the env builder's first importer. Found by Sol (gpt-6.2-sol) reviewing 65528e060d. |
||
|
|
49d471dee4 |
fix(plugins): check a dashboard plugin's name after the host's queued releases
4560099171 checked a dashboard plugin path's home name before calling _call, but _call first sends the releases queued by collected object proxies, a blocking round trip to the host. A repoint during that wait still sent the host the stale path. _call takes a before_send hook that runs once the releases are flushed, right before the method goes out, and asgi_request checks the path there. Found by Sol (gpt-6.2-sol) reviewing 4560099171. |
||
|
|
08d2bf23bd |
fix(plugins): read the provider registry for the host's home at a cold env build
_env imported the child-env builder in the caller's context. The first import of that module builds its provider blocklist from the registry, which imports an in-process home's provider plugins. A start that was that first import, called from a context bound to another profile whose link had since been repointed, imported the other directory's provider code, although the host's own home had just passed its check. The import now runs inside the host's base context with the env build, so the registry is read for the home the start checked. Found by Sol (gpt-6.2-sol) reviewing 4560099171. |
||
|
|
b8241f0570 |
fix(plugins): check a dashboard plugin's home name right before the host loads it
A forwarded dashboard request looks its plugin up, then waits in its profile's queue (up to 60 s), and the host may start cold, before the host loads the plugin's path. The lookup's checks run at lookup time. If the request came through a second live name for the home and the name the path was read through was repointed meanwhile, the host loaded the other directory's plugin code, while the request's own name still passed (Greptile on #159450). PluginHost.asgi_request, which both hosted routes call, now runs refuse_moved_plugin_dir() on the path after the host is up and right before it hands the host the path. Reading the plugin from the verified directory instead is the structural fix, left for a follow-up. |
||
|
|
198304c327 |
fix(plugins): check a host start's name again before its provider scan
7b27aec0c7 moved _env's check from before the ambient-credential scan to before the child's env is built, leaving the scan itself unchecked. The build reads through the name, and the provider layer rereads the plugin dirs once its stamp check is due (1 s). A link repointed while the build ran therefore let the scan import the other directory's provider code into Hermes before the start's final check refused it (Greptile on #159450). _env keeps both checks: before the build and again before the scan. The ambient-credential test gains a repoint during the build, with the stamp check made due as a long build would. |
||
|
|
2e465036cc |
fix(plugins): refuse a host start before it builds the child's env
22970d3213 checked a start's home name before the ambient-credential scan, but building the child's env reads the provider registry earlier. The first import of tools.environments.local builds its blocklist from PROVIDER_REGISTRY, and the registry's first read lists the bound home's provider plugins. Either read imports them through the name, in Hermes for an in-process home, so a link repointed before the start loaded the other directory's provider code before the start refused (Greptile on #159450). The test also showed it for a process whose registry had not been read yet. _env now checks the name first, before it imports the env builder or builds anything. The ambient-credential test is parametrized for a process that has not imported the env builder yet. |
||
|
|
8872a587b7 |
fix(plugins): refuse a host start before it scans a moved home's providers
A host start reads which providers take ambient credentials with list_providers() in the host's context, which this PR binds to the profile's name. That call rescans the home's provider plugins through the name and imports them, into Hermes itself for a home whose plugins.isolation is in_process. 5954d9f98c checks the name only after the child's env is built, as reads have no effect until Popen. This read runs code: a link repointed before the scan imported the other directory's provider plugins into Hermes, and the start then refused. The start now checks the name right before that scan and refuses with PluginHomeMoved. A repoint landing during the scan itself is left, like the window between the start's last check and Popen. Provider lookups by other bodies bound to a moved name are left as well (restart required). Found by Sol (gpt-6.2-sol) reviewing 513e598f2e. |
||
|
|
c83adf6480 |
fix(plugins): keep a host context stale until a check after its build passes
513e598f2e marked a host's base context stale only when a start's last check refused. A context is built through the profile's name, so it holds the other directory's secrets whenever the link was repointed during the build. Two more paths kept such a context: - The rebuild cleared the flag as soon as it finished. A start that then failed before its last check, because the other directory's plugins.host.launcher did not parse, left a context marked fresh. - The context built with the host was never checked. The first start then refused in owner_home while the link led elsewhere, and once it led back the start reused the context. In both cases, once the link led back, the next start kept the context and parent-side plugin calls with no caller ran with the other directory's secrets. A rebuild now marks the context stale until the start's last check passes. Construction checks the name right after its build, so a host built through a moved name rebuilds at its first start. The refusal no longer sets the flag itself, because every context it could find is already marked. An unmoved host still builds its context once. Found by Sol (gpt-6.2-sol) reviewing 513e598f2e. |
||
|
|
94803d9d90 |
fix(plugins): rebuild a host's context after a refused start
A start that moves to a new profile name rebuilds the host's base context, whose secret scope under multiplexing is read from the profile's .env through that name. When 5954d9f98c refused such a start because the link was repointed meanwhile, the rebuilt context still held what the other directory's .env held. Once the link led back, the next start found the same name and skipped the rebuild. Parent-side plugin calls with no caller then ran with the other directory's secrets. A refused start now marks the context stale, and the next start rebuilds it. Found by Sol (gpt-6.2-sol) reviewing 5954d9f98c. |
||
|
|
435edac114 |
fix(plugins): refuse a host start whose name moved while it read through it
ensure_started checks that the profile's name leads to the manager's directory once, when it reads owner_home. Its context, launcher and child env are then built by reading through that name. A link repointed in between made the start read the replacement directory's config and .env, and launch a host there with the original profile's credentials (Greptile on #159450). The start now re-checks the name after its last read (the child's env) and before Popen, and refuses with PluginHomeMoved if the name leads elsewhere. No host process starts. A host already running keeps reading through its name. That is a separate design question and is not changed here. |
||
|
|
ce8fa9cdc6 |
fix(plugins): refuse plugin work once no profile name leads to its directory
A linked profile's plugin manager runs plugin code under the profile's name, because a marked profile whose directory is a link out of the Hermes root is found by that name only. When no name led to the manager's directory any more, owner_home fell back to the directory itself. That happens when the link is repointed after the process remembered its key, renamed out of the root, or removed. The directory alone reads as an unmarked profile, so the run-elsewhere marker went unseen and a marked profile's own launcher ran (Greptile on #159450). owner_home now raises PluginHomeMoved in that state. Discovery, loads, plugin ctx calls and host starts are refused until a restart opens the profile again. Unloading still runs, under the directory, because it stops plugin work. A host restarted after a crash unloads its plugins and logs the refused reload instead of raising from its thread. The tests that pinned the fallback now pin the refusal. The test of a start's launcher check moves the start's name mid-start instead, because a start with no name is now refused before it builds anything. |
||
|
|
31eb4a14bc |
refactor(plugins): choose a host's launcher in plugin_isolation
b5e2a1dd03 had plugin_host_profiles import plugin_host for the extraction's launcher, while plugin_host already imports plugin_host_profiles: a cycle, where the repo's rule puts a shared name in a lower module. The launcher choice moves next to host_launcher in plugin_isolation, which both already import: is_launch_home, launcher_for (no longer handed host_launcher, which now lives beside it), extraction_launcher, and the start's lend as lending_launcher. No behaviour changes. |
||
|
|
776d35f243 |
fix(plugins): ask the marker again before an extraction takes its start's launcher
A host start lends the launcher it chose to the cold provider extraction it runs while building the child's env (f8c6a0bab7). The extraction used it without asking the run-elsewhere marker, where the extraction on main and on b5e2a1dd03 asked it at extraction time. A profile marked between the start's choice and the extraction had its extraction run under its own plugins.host.launcher. extraction_launcher now takes the lent launcher only while the home still runs here; a marked home gets a fresh choice, which is the managed overlay's launcher alone. |
||
|
|
76ec0ee54a |
fix(plugins): lend a host start's launcher to the extraction it runs
A host start with no extraction cached extracts the profile's hosted model providers in the host's own context while it builds the child's env. The previous commit had that extraction choose the launcher again there. Inside a launch-profile body that is not multiplexed (the TUI gateway binds one even single-profile), the start reads its launcher through the launch scope, the .env as it is now, while the host's context binds no scope and the second choice read the process env, as loaded before a .env edit: two launchers for one start. The start now lends the launcher it chose (_START_LAUNCHER) around that step, and extraction_launcher uses it; an extraction outside a start still chooses for itself. |
||
|
|
5c1e5630ee |
fix(plugins): extract hosted providers under the launcher their host start chose
A host start with no extraction cached extracts the profile's hosted
model providers while it builds the child's env, from the host's own
context. That extraction called host_launcher() there, while the start
itself chose its launcher through _launcher_for. The host's context
holds the profile's secret scope only while multiplexing is
process-wide, so under task-local multiplexing (the desktop cron ticker)
the extraction expanded the profile's launcher ${VAR}s against the
launch profile's env: another runner, or none.
plugin_host.extraction_launcher(home) gives the extraction child the
launcher a host start for that home chooses. Its env stays free of
credentials.
|
||
|
|
61e54090d4 |
fix(plugins): resolve a launch host's .env once for its launcher and child
Under multiplexing the launch profile's host launcher resolved the
profile's .env templates against the launch env frozen when multiplexing
began, while the host child's env, built a moment later for the same
start, resolved them against the live env. A ${VAR} the .env references
that another profile's task changed since gave the launcher and its child
two values for one setting.
_launcher_for now returns the env its templates resolved against, and
the start passes that same mapping to served_profile_child_env and the
ambient-credential overlay (template_env=). launch_secret_scope takes
the mapping (template_env=) instead of deciding it from a flag, so the
plugin host reads the frozen env once per start.
|
||
|
|
3cccbcafa2 |
refactor(plugins): decide a host start's ownership once
_launcher_for and the child-env builder each asked _is_launch_home for the same start. hermes_home_key remembers a path's first strict resolution, so the two reads agree in practice, but a start should not depend on that (Sol's nit on 53b7106218). ensure_started now asks once and passes the answer to _argv/_launcher_for and _env. No behaviour change; the plugin host files pass unchanged. |
||
|
|
3fa9572cb1 |
fix(plugins): give a host child's env the launcher's profile ownership
The launcher decides whether the host's home is the launch profile's by the key the process remembered for its own path. The host child's env did not: served_profile_child_env asked _is_routed_home, where the process's own name leads now. After the launch link is renamed the old name leads nowhere, so a crash restart scrubbed the credentials only the service env holds (systemd Environment=) and resolved the launch .env as another profile's, while its launcher still got them: the host started and its plugins could not sign in (Greptile on 109d8ff1d5). The other way round, after the launch link is repointed at a secondary's directory, that secondary's host child kept the launch profile's credentials, as on main. _is_launch_home is now the one answer for a host start. served_profile_ child_env takes own_profile for a caller that decided it; the plugin host passes it, and it drives the credential scrub, the overlay's .env templates, the bootstrap tokens and the bridge markers. The launch-residue strip keeps its own check. _hosted_ambient_credentials takes the same answer, and now binds through bind_state rather than a raw set_secret_scope (HX016). Tests: - the rename test's stand-in launcher records the child's env: the restart after the rename ran without the service-only key on 8a8a2dfa14 (and with not-the-launch-env in the template row); here both hold; - test_a_secondary_hosts_child_takes_no_launch_only_credential_after_the_ launch_link_is_repointed_at_it[bound_to_the_secondary|none]: red on 8a8a2dfa14 and on main (the launch key reached the child), green here. A mutant leaving the overlay on the live check fails the template row. |
||
|
|
6e2685ed45 |
fix(plugins): keep the launch launcher's .env templates its own after a rename
_launcher_for recognises the launch profile by the key the process remembered for its own path, so it still builds the launch scope after that link is renamed. launch_secret_scope then let build_profile_secret_scope ask _is_process_home, where the old name leads nowhere: the launch .env counted as another profile's, and a template naming an env-only launch key (systemd Environment=) fell back to its default, or stayed literal (Greptile on 9eb6c81a6c). launch_secret_scope takes the caller's process_home and passes it to build_profile_secret_scope; the launcher passes True, the decision it already made, as it passes False for every other profile. Other callers keep the live check: the dashboard's launch scope is built for get_process_hermes_home(), which follows an embedding host's per-turn HERMES_HOME mirror, where that check keeps a mirrored profile's templates off the launch env. The rename test gains a template_of_an_env_only_key row: it fails on 9eb6c81a6c (the restart after the rename ran not-the-launch-env) and passes here; main fails both rows earlier, at the first start. |
||
|
|
e480785631 |
fix(plugins): resolve the launch launcher's .env templates against the frozen launch env
f905ed0d51 rebuilds the launch scope for the launch profile's launcher at start. launch_secret_scope layers the launch env frozen under multiplexing, but its .env templates resolved against the live env, so a write to the live env after a launch body bound (another task's, under multiplexing) reached the launcher while the body kept its value. Main and dd597f44d7 expanded the launcher with the body's values (Sol on f905ed0d51). launch_secret_scope(frozen_templates=True) resolves the .env templates against the same launch env it layers under, with this process's own dotenv output peeled back as for the live env (resolve_home_dotenv's new base_env, threaded through build_profile_secret_scope as process_env). Only the launcher opts in; other launch bodies keep resolving against the live env. Single-profile the launch env is the live one, so nothing changes there. The task-local multiplexing test is renamed (nothing is lent now) and gains an env_file_template row: it fails on f905ed0d51 (the value written after the bind ran) and passes on main and dd597f44d7. A new test loads a .env whose template names a key the file only sets later, through the real dotenv loader: the launcher takes the default, as the process loaded it; a mutant without the peel fails it. A test stub of build_profile_secret_scope now takes the keyword arguments. |
||
|
|
a482edae7e |
fix(plugins): rebuild the launch scope for a launch body's host start
faa2ff9277 lent a launch-profile body's scope to the launch profile's launcher while the name it was read through led to the host's directory. A body that bound while the process's own link pointed elsewhere, then found it restored before the start, passed that check, so the launch host took the other directory's .env values. Main did the same: it expanded the launcher in the caller's context (Sol on 98afe23b63). A launch-profile body (a caller bound to the launch profile's own scope, unstamped or stamped with a home keyed to it) now only selects the launch scope for the launch profile's launcher. The scope is built again from the host's home with launch_secret_scope, under the body's carried task-local multiplexing; no caller's scope is lent. Because the launch env is frozen when the body first bound under multiplexing, a name it froze without still stays unresolved, as in the body. test_a_launch_body_bound_while_the_process_link_pointed_elsewhere_gives_ the_launch_host_its_own_files [tui_gateway, dashboard] fails on 95f4cf4417 and on main (the moved-away directory's runner ran) and passes here. Mutants of the new predicate each fail a test: no bound scope required (the single-profile process-env test), any stamp accepted ([secondary] row), only unstamped scopes ([dashboard] rows); dropping the carried multiplexing fails the task-local test, carrying it outside a launch body fails the [secondary] row. |
||
|
|
f9218c8cc0 |
fix(plugins): resolve another profile's launcher .env templates by the same decision
98afe23b63 builds a non-launch profile's launcher scope with
build_profile_secret_scope, but its .env template expansion still asked
_is_process_home, where the process's own path leads now. After the
launch profile's link is repointed at a secondary's directory, the
secondary's ${NAME:-default} templates then resolved against the launch
env; a body bound to the secondary before the move had the right value
on main and dd597f44d7 (Sol on 98afe23b63).
build_profile_secret_scope takes an optional process_home that replaces
that live check for the template lookup and the bridged allow-all seed;
every other caller keeps the default. The launcher passes False, as it
already decided by the key remembered for the process's own path.
test_a_secondary_hosts_env_templates_resolve_as_another_profiles_after_
the_launch_link_is_repointed_at_it: [bound_to_the_secondary] fails on
98afe23b63 (the launch runner ran) and passes on dd597f44d7 and main;
[none] fails on all three. Both pass here; a mutant that drops the
launcher's process_home=False fails both.
|
||
|
|
1f1773f1c4 |
fix(plugins): build another profile's launcher scope from its own files
With nothing lent, a profile other than the launch one got owner_secret_scope(home), which asks whether home is the process's own profile by where the process's own path leads now. After the launch profile's link is repointed at a secondary's directory that answer is yes, so the secondary's launcher got the launch profile's env-only values (Sol on 7d05d35d4f). _launcher_for already decided ownership by the key the process remembered for its own path; build the other profile's scope from its files (build_profile_secret_scope) by that decision. test_a_secondary_host_takes_no_launch_env_value_after_the_launch_link_is_ repointed_at_its_directory: [bound_to_the_secondary] fails on 7d05d35d4f (the launch runner started the secondary's host) and passes on dd597f44d7 and main, which lent or used that caller's scope; [none] (no caller, as a crash restart) fails on dd597f44d7 and main too. A .env template in that secondary's files still resolves against the process env after such a repoint (_expand_dotenv_templates asks _is_process_home): that is the shared scope layer's, with the rest of the repointed-link class. |
||
|
|
0ba3333479 |
fix(plugins): lend the dashboard's launch-profile scope to its launcher too
7d05d35d4f lent only an unstamped scope as the launch profile's. The
dashboard binds its own profile's launch scope stamped with the process
home (web_server_profiles._config_profile_scope), so a host started by a
single-profile dashboard request read the process env instead, and a
launcher value only the .env held stayed literal; main and dd597f44d7
resolved it (Sol on 7d05d35d4f).
Lend the launch profile's own scope whether unstamped or stamped: its
source (the stamp, else the process's own name) must key to the started
home, which must be the launch profile's, and still lead there. A scope
stamped with any other profile is still never lent.
The launch-profile binding test gains a dashboard row: it fails on
7d05d35d4f ('${PLUGIN_RUNNER}' not found) and passes on main and here.
The repoint fixture can now point the link at the launch home (its
runner env-only), and a fourth row binds through the link before it is
repointed there: it fails on a mutant that skips the stamp's own key.
|
||
|
|
ffd8a8f089 |
fix(plugins): lend only the launch profile's own scope to a launcher
dd597f44d7 lent a caller's stamped scope while its name led to the host's directory under the key the process remembers for it. A request that bound while the link pointed elsewhere and found it restored before the start still passed both checks, so the host took launcher values from the other directory (Greptile on dd597f44d7). A stamped scope holds what a profile's files held when the caller read them through a name; the scope the start builds for any profile but the launch one (owner_secret_scope) reads the files of the directory the host starts in, which is what the launcher wants. So stamped scopes are never lent. Only the launch profile's unstamped scope is, for the launch profile's host, while the process's own name leads to its directory: it holds env-only values no file can rebuild. The moving-link test gains a row for the restored link: it fails on dd597f44d7 (the new directory's runner ran in the old directory's host) and on main. test_a_launch_body_bound_before_its_own_link_was_repointed_ lends_nothing_to_the_new_directorys_host pins the remembered-key half for the launch scope (fails on main and on a mutant without it); the renamed-launch-link test now also starts the host inside a launch body bound after the rename, which pins the realpath half (fails on a mutant without it). |
||
|
|
00ec9ed1f1 |
fix(plugins): lend a caller's scope only while its name leads to the host's directory
5dd81681db lent a caller's secrets when its stamp's remembered key matched the started home's. A repointed link keeps its old key, so a caller bound to the name after the repoint (holding the new directory's .env) lent those values to the host of the manager opened by that name, which starts in the old directory; and a caller bound before the repoint (holding the old directory's values) lent them to the host of the directory the name leads to now (Sol on 31e3d49d39). Lend only while the caller's name, or the process's own for an unstamped launch scope, leads to the started home's directory under the key the process remembers for it, as PluginManager._leads_here asks. Otherwise the start builds the home's own scope, as before 5dd81681db. test_a_caller_bound_to_a_repointed_profile_link_lends_nothing_to_the_ old_directorys_host fails on 31e3d49d39 (the new directory's runner ran) and on main, and passes on 6d69a64015 and here. test_a_caller_ bound_before_its_profile_link_was_repointed_lends_nothing_to_the_new_ directorys_host pins the remembered-key half: it fails on main and on a mutant that checks only where the name leads now. |
||
|
|
77db550195 |
fix(plugins): keep the caller's task-local multiplexing with a lent launcher scope
5dd81681db binds a caller's secrets for the launcher in a fresh context.
That context dropped the caller's task-local multiplexing (the desktop
cron ticker), so a name missing from the lent launch scope fell through
to the live process env, where the caller's body leaves it unresolved
(Sol on 5dd81681db).
Carry the caller's multiplexing into the fresh context whenever it lends
its scope; nothing else from the caller's context comes along.
test_a_lent_launch_scope_keeps_the_callers_task_local_multiplexing_for_
a_missing_launcher_value writes a launcher argument into the process env
after the launch body bound its scope: on 5dd81681db the launcher got the
written value, on main and here it stays '${RUNNER_TAG}', as in the body.
The secondary row of test_a_caller_bound_to_another_profile_lends_its_
scope_to_no_other_profiles_launcher now also edits the launch .env after
load: a mutant that carries the flag when nothing is lent reads that file
again for a launch-profile start from a secondary-bound caller, and fails
the row; it passes on 6d69a64015 and here.
|
||
|
|
c8b72cf568 |
fix(plugins): let a caller bound to the started profile lend its launcher values
Since 7bb619bb8a the launcher was chosen in a fresh context, so a host
started inside the TUI gateway's launch-profile binding (its .env over the
live env, bound even single-profile) dropped that scope and expanded
${PLUGIN_RUNNER} against the process env: a value only the .env held
stayed literal and the host failed to start (Greptile on 6d69a64015).
Main expanded it from the caller's scope.
Take the caller's bound secrets first when they are the started profile's:
stamped with its home, or unstamped (the launch profile's) for the launch
profile. A marked profile still reads the process env, and with no such
caller the choice is unchanged: the process env for the launch profile
outside multiplexing, its own scope otherwise.
test_a_host_started_inside_the_launch_profiles_bound_scope_takes_its_
launcher_value_from_it fails on 6d69a64015 ('${PLUGIN_RUNNER}' not found)
and passes on main and here. test_a_caller_bound_to_another_profile_lends_
its_scope_to_no_other_profiles_launcher pins the other side: both rows
fail on main and on a mutant that lends any bound scope; the launch row
fails on one that lends an unstamped scope to every profile.
|
||
|
|
5a819ef794 |
fix(plugins): read the launch profile's launcher files through its current name
d91acd10e8 built a renamed launch profile's launcher scope with
owner_secret_scope(<the process's own path>), so after the rename its
files were read through the old name, which leads nowhere: a value only
the launch profile's .env held stayed a literal ${VAR} on a crash
restart, and an .env edit was ignored for the frozen env value (Sol on
5e8d9a7038).
Build launch_secret_scope(home) once the start's directory is known to be
the launch profile's: the launch env, with the files read through the
name that leads there now.
The rename test now also takes a launcher value only the launch profile's
.env holds: red on 18510dfbf2 (the restart passed '${RUNNER_TAG}'), green
here. It fails on main at the first start, whose multiplexed launcher read
only the process env (a real process loads that file into it at start).
|
||
|
|
df1bcab8ea |
fix(plugins): read a sibling profile's launcher from its own files outside multiplexing
4450d0a128 chose the launcher scope by is_multiplex_active() inside the fresh context. A process that is not a multiplexer still serves a sibling in a task (the desktop backend's cron ticker marks it with set_multiplex_context), and that task-local flag does not reach a fresh context: such a host start read the sibling's launcher against the process env, the launch profile's value for the name (Sol on 5e8d9a7038). Main kept the caller's scope there. Decide by whose profile the start is for instead: a profile a plugin runs elsewhere, and the launch profile outside multiplexing, read the process env; any other profile expands through its own secrets whatever the flag; the launch profile under multiplexing through its own scope. The test starts a sibling's host under task-local multiplexing with its variable in its .env and a different value in the process env: red on 0d64a03a7b (the launch value ran), green on main and here. |
||
|
|
dbae24663d |
fix(plugins): keep the launch profile's launcher keys after its link is renamed
Under multiplexing 7bb619bb8a expands a launcher through owner_secret_scope
of the start's home, which decides the launch profile by comparing that
path with the process's own. After the launch profile's link is renamed,
the manager answers to the new name, the process still names its profile
by the old path, and owner_secret_scope took the new name for another
profile: the launch env was dropped, so a crash restart left an env-only
${VAR} literal (Sol on 7bb619bb8a). Main read the process env there.
Decide the launch profile the way serves_routed_profile does, by the
process's remembered key for its own path, and build the launch profile's
scope (launch env plus files) when the start's home keys the same
directory.
The test renames the link of a multiplexed launch profile whose launcher
variable only the launch env holds, then kills its host without updating
the process's own path: red on 4450d0a128 (the restarted host's load fails
on '${PLUGIN_RUNNER}'), green on main and here.
|
||
|
|
5abe9f27c7 |
fix(plugins): expand a marked profile's managed launcher against the process env
7bb619bb8a expanded every launcher's ${VAR}s through a scope built for the
start's home. For a profile a plugin runs elsewhere, host_launcher takes
the launcher from the managed overlay alone, and #156725 specifies that its
refs expand against the process env, as for any profile
(test_a_managed_launcher_expands_its_env_refs_for_a_marked_profile_too).
Under multiplexing a variable only the process env held therefore stayed
literal: FileNotFoundError '${PLUGIN_RUNNER}' at the host start (Sol on
7bb619bb8a).
Bind a profile's own secrets for the launcher only where the process env
is the wrong source: under multiplexing, for a profile run on this host.
A marked profile, and every start outside multiplexing, expand against
the process env again, with only the home bound, as on main. That also
keeps single-profile launchers on the values main read (the managed and
project dotenv layers the process loaded), which a rebuilt scope does not
replay.
The test starts a marked profile's host under multiplexing with the
managed launcher's variable in the process env only: red on 7bb619bb8a,
green on main and here.
|
||
|
|
33e2c2a17d |
fix(plugins): read a host launcher's variables from its own profile
270e37621f chose the host launcher in the caller's context with only the
home rebound, so its ${VAR}s expanded through whatever the caller had
bound. A crash restart runs on a bare thread with nothing bound, where
config expansion reads os.environ: under multiplexing a secondary
profile's launcher variable from its .env stopped expanding, or took the
launch profile's value for the same name (Greptile on 270e37621f; the
same as main, whose launcher read the caller's context too).
Choose the launcher in a fresh context bound to the start's home and its
own secrets (bind_state with owner_secret_scope, not hydrated, no
terminal policy): the launch profile's env-only keys and files, any other
profile's own files. The answer no longer depends on who started the host.
Single-profile values are unchanged: the user .env already overrides shell
exports in os.environ, as launch_secret_scope does.
The test runs a real crash restart under multiplexing in two rows: a
secondary with the variable in its .env and a different launch value (red
on 270e37621f and main: the launch runner ran) and the launch profile with
an env-only variable (red on ab028cc238: '${PLUGIN_RUNNER}' not found).
It replaces the test that bound a hand-built caller scope.
|
||
|
|
9a322fb3f4 |
fix(plugins): expand a host launcher's variables in the caller's scope
ab028cc238 chose the host launcher inside the host's own context so its
config would be read in the home the start took. That context holds only
the profile's own secrets (build_profile_secret_scope), so under
multiplexing a launcher written as ${VAR} whose value only the caller's
scope holds (a launch profile's env-only keys: systemd Environment=, op
run) no longer expanded, and the literal placeholder reached
subprocess: FileNotFoundError '${PLUGIN_RUNNER}' (Greptile on ab028cc238).
Choose it with only the home rebound to the one the start took
(_plugin_home_scope, the binding plugin code runs under): config is still
read there, and ${VAR}s expand through the caller's secret scope as they
did before ab028cc238. Not
owner_secret_scope() per start, which would rebuild the profile's secrets,
external sources included, at every host start and crash restart.
|
||
|
|
fded42cfd1 |
fix(plugins): read a host's launcher config in the home it starts in
_argv chose the launcher with host_launcher(home=...), which reads plugins.host.launcher (and expands its variables) through the caller's binding. A load binds the profile name it read, and a rename can retire that name before the load starts the host: the start then took the new name for its context, environment and working directory, but the launcher lookup still read config under the old name, which now fails with "Named profile home does not exist". Main bound the resolved directory for loads, so its caller binding never went stale. Run the launcher choice in the start's own context, which binds the home the start took. Found in the sol-loop review of 01b93a32c5. |
||
|
|
2cac5f0191 |
fix(plugins): ask about a host's launcher for the home its start took
ensure_started reads the manager's owner_home once and builds the host's environment and working directory from it, but _argv read owner_home again for the launcher's run-elsewhere check. Since owner_home follows a profile's name, a name that appeared between the two reads (a link made while the host was starting) gave one start two homes: the launcher was judged for the new name, the environment for the directory. Use the home the start took. Reported by Greptile on 9e7a40f2f8. |
||
|
|
90e64364e4 |
fix(plugins): retry a host's new home after its context failed to build
A start that moves the plugin host to the manager's current home set `_home` before building that home's context. When the build raised (the profile's secret scope unreadable), the next start saw the home unchanged, skipped the build and started the host with the context of the home it had left: the old link name, gone after a rename. Put the previous home back when the build raises, so the next start builds the context again. |
||
|
|
02bf2f6a48 |
fix(plugins): tell a plugin its profile from the host it loads into
`PluginHost.load` computed the plugin's `ctx.profile_name` from the base context before `ensure_started`, which is where a start now takes the manager's current home. After a linked profile is renamed and the host crashes, the first plugin the restart reloads was told the old profile name while the new host, and every later load, ran under the directory. Compute it after the host has started, in the context of that host. |
||
|
|
b39e870d1e |
fix(plugins): stop binding a linked profile's old name after a rename
A process keeps one plugin manager per resolved directory. When a profile whose home is a link is renamed while the process runs (the dashboard, a multiplexed gateway), the next request for the new name gets the same manager, still holding the old name. The manager kept binding that name for discovery, a plugin's calls and the plugin host, and discovery had recorded each user plugin's path through it. After a host crash, the restart reloaded every plugin from a path that no longer exists, and the plugin's tools were gone until the process restarted. On main the manager bound the resolved directory and recovered. - `owner_home` is now a property. It returns the name while that name still leads to the manager's directory, and the directory itself once it doesn't. A marked profile is still found by its name, and a marker does not follow a rename by design. - The plugin host takes its home at each start, not only when it is first built. - Discovery reads user plugins from `home_path`, so a plugin's path survives a rename of the link, as it did on main. A host already running when the link is renamed keeps the old name in its environment until it restarts. |
||
|
|
6ed7199c07 |
fix(plugins): run a marked profile's plugin code under the name it was opened by
#156725 refuses to run a profile that a plugin runs elsewhere, and asks the marker by the home's name. b912bfb00e7 passed that name (owner_home) to host_launcher() for the plugin host's argv only. The plugin manager still bound home_path, the resolved directory, around discovery, loading, unload and a plugin's calls, and PluginHost._home was home_path too. For profiles/<name> linking to a directory outside the Hermes root, code under those bindings asks the marker about a directory with no marker folder above it, and is told the profile runs here: - A model-provider plugin's extraction (plugin_host_profiles._extract) started the launcher the profile's own config.yaml names. It runs while a bundled plugin loads (its imports list the providers) and when the host starts (_hosted_ambient_credentials). `hermes -p ops tools list`, `profile list` and `memory status` each started it once with a cold extraction cache. - The host child's environment was built from that directory's .env, which reads as empty for a marked profile: a PYTHONPATH there ran a module from it in the host child. Bind owner_home wherever the manager or its host runs code. home_path stays the registries' key; for a home that is not a link both name the same directory. |
||
|
|
fe9a4b58ec |
feat(profiles): never run a profile on the host while a plugin runs it elsewhere (#156725)
* feat(profiles): never run a profile on the host while a plugin runs it elsewhere
One host gateway serves every profile by default and runs each profile's
cron, messaging platforms, Kanban dispatch and Webapp; the CLI, TUI and
desktop build agents on the host too. A plugin that runs a profile's whole
backend somewhere else (for example in a sandbox, through its own host
launcher) had no way to stop the host from also running that profile outside
it, reading config the sandbox can write.
A host-side plugin now marks such a profile in host-only storage under the
Hermes root, never in a profile home:
<hermes root>/profiles_run_elsewhere/<profile>.json
{"plugin": "<plugin name>", "since": "<ISO 8601 UTC>"}
The file's presence is the marker, and an unreadable marker still marks the
profile. Writers write a dot-prefixed temp file in the folder and rename it
over <profile>.json. hermes_cli.profiles_run_elsewhere reads it and gives
host-side plugin code mark_profile_run_elsewhere() and
clear_profile_run_elsewhere().
For a marked profile:
- profiles_to_serve() leaves it out, the default profile included, unless
the caller passes include_run_elsewhere=True. The host gateway stops
serving it at its next rescan, and the desktop cron ticker, /p/<profile>/
routing and the dashboard's cron and session fan-outs skip it. Callers
that only look for live gateways, count installed homes or read which
worktrees a resumable subagent pins opt in (host attach, the launch
profile policy, the multiplex counts, the worktree sweep's pin view).
- AIAgent refuses to build an agent for it (ProfileRunsElsewhere), whichever
frontend asks, including a multi-profile host building a sibling's agent.
- CLI commands that run a turn exit 1 before any banner, TUI or gateway
contact; `hermes serve` and `hermes dashboard` exit 78 before attaching or
binding; the gateway process exits 78 before reading config.
- ensure_gateway_runtime() answers inaccessible / profile_runs_elsewhere
before discovery, so nothing starts or attaches to it on the host.
- The dashboard's cron, session, file and Webapp requests for it answer 409,
the desktop cron ticker's gate refuses it, and the Kanban dispatcher
leaves its cards in ready (skipped_nonspawnable).
A process that cannot list the marker folder (permission denied) is the
backend the plugin runs, not the host: it refuses nothing. Any other error
reading the folder fails closed. A profiles folder the process cannot list
shows only the process's own profile instead of raising PermissionError.
_seed_file_if_missing moves to profiles_initialization.py, its only caller,
to keep profiles.py under its size cap.
* fix(profiles): close review gaps in the run-elsewhere marker
Follow-up to "feat(profiles): never run a profile on the host while a
plugin runs it elsewhere", from the first review of #156725.
Checks added where a host process could still run a marked profile:
- cron.scheduler_tick.tick() returns before the tick lock, the due scan or
any job for a marked profile, so every in-process ticker skips it: the
gateway's (its launch profile included), the desktop's, and the built-in
fallback an external provider starts. CronScheduler.claim_fire() claims
nothing for it, for a provider's inbound fires and the misfire sweep.
- AIAgent.run_conversation() makes the check AIAgent.__init__ makes, so an
agent built before the profile was marked (a gateway's cached agent, an
open dashboard or TUI session) runs no further turn.
- The dashboard's deferred agent build refuses first, before it binds the
profile's scope or starts its MCP servers.
- `hermes gateway run` exits 78 in _prepare_agent_startup, with or without
--force: before plugin discovery, shell-hook registration and the
host-gateway attach guards.
The marker module:
- run_elsewhere_for_home() reads the home as written and as resolved, and
refuses when either reading is marked. A symlink or junction to a profile
home, a relative or `..` path, or the profile id in another letter case
now reaches that profile's marker.
- mark_profile_run_elsewhere() publishes a new marker with a hard link,
which never replaces a file: of two plugins that both found no marker,
one claims the profile and the other gets the ValueError. Where the
filesystem has no hard links it renames as before.
clear_profile_run_elsewhere() returns False without unlinking when it
finds no marker, so it cannot remove one published after it looked. No
lock is taken.
- Only a missing marker folder means nothing is marked. A regular file in
its place refuses every profile, like any other read error.
- The folder reader returns one shape, _MarkerFolder(names, error).
- mark_profile_run_elsewhere, clear_profile_run_elsewhere and run_elsewhere
are listed in plugin_api.json and public-api.md is regenerated, so
`hermes plugins validate` accepts a plugin that imports them by name.
Corrections to that commit's message:
- "A profiles folder the process cannot list shows only the process's own
profile instead of raising PermissionError" now holds only for a process
whose own home is a named profile under that folder (the backend a
plugin runs elsewhere). Any other process gets the PermissionError, as on
main, so activate_multi_profile_hosting_eagerly() fails closed again for
a default-profile host that cannot list the folder.
- "Any other error reading the folder fails closed" did not hold for a
regular file at the folder's path, which read as "nothing marked". It
holds now.
- "Writers write a dot-prefixed temp file in the folder and rename it over
<profile>.json": the Python API's first write of a marker is the hard
link above. Its rewrite of an existing marker, and other writers, still
rename.
Not changed: a gateway or a serve/dashboard backend already running as the
marked profile is not stopped. It runs no further turn and no cron job for
the profile, and stays up until it is stopped.
* fix(profiles): load no env file or secret source from a marked home
Second follow-up to "feat(profiles): never run a profile on the host while
a plugin runs it elsewhere", for the review finding "CLI runs code before
refusing" on #156725.
While a plugin runs a profile elsewhere, the backend it runs writes the
profile's home. Every `hermes` start loads that home when hermes_cli.main
is imported (load_hermes_dotenv), before argparse and before any refusal,
and so does the plugin's own host process. A `secrets:` source that
backend wrote into its own config.yaml therefore ran on the host as the
user: `secrets.command` through /bin/sh on Linux and macOS,
`secrets.onepassword.binary_path` as a program on every OS. A .env it
wrote reached the environment of every such start, overriding what the
process already had.
Now a dotenv load whose home is marked takes nothing from that home:
- load_hermes_dotenv() does not read, rewrite or publish the home's .env,
does not load .op.env and resolves no `secrets:` source. It asks once
per load (run_elsewhere_for_home: a path resolve and a listing of a
folder that is normally not there) and treats the two files as absent,
so the project .env takes the precedence it has for a home without a
.env. The project .env, the administrator-managed .env, the
config-backend boot and the terminal bridge are unchanged.
- The config-backend bootstrap (_bootstrap_env) takes no selector or plane
credential from a marked home's .env or .op.env, also when it runs
before the first load. bootstrap_deployment() passes the load's answer
on, so one load asks once.
- hydrate_profile_secret_sources() resolves nothing for a marked home, so
a host gateway or dashboard that serves the profile runs none of its
sources either.
A process that is denied the marker folder is the backend the plugin runs:
its home reads as not marked and it loads its own files as before. A
marker folder that cannot be read for any other reason already refuses
every profile; no profile's env files or secret sources are loaded either
until it can be read, and the log line says so.
What this changes for a marked profile: a host process started under its
home has none of its .env values in the process environment and none of
the keys its secret sources supply. The marking plugin supplies what its
own host process needs.
Not covered: hermes_cli.config.load_env() and the readers built on it
(get_env_value, reload_env) still open the .env file when asked, and the
secret scope a multi-profile host builds for a profile it serves still
reads it. Neither runs anything.
* fix(profiles): start no command and read no env value from a marked home
Third follow-up to "feat(profiles): never run a profile on the host
while a plugin runs it elsewhere" (#156725), on top of "load no env file
or secret source from a marked home".
While a plugin runs a profile elsewhere, the backend it runs writes the
profile's home. Two kinds of host process still acted on what that
backend wrote there (measured under a marked profile with stand-ins that
only append a line to a file):
- Commands that start a command the profile's own files name, without
building an agent. `hermes hooks test` ran a shell hook from
config.yaml. `hermes mcp test` started an `mcp_servers` stdio command,
and sent an HTTP server's request to the address in its entry.
`hermes secrets onepassword status` and `sync` ran the program
`secrets.onepassword.binary_path` names. `hermes send` loaded the
home's .env into the process with a loader of its own.
- Code that reads one env value on demand. The previous commit stopped
the dotenv load; load_env() and get_env_value() still opened the
home's .env. So `hermes status` listed keys that backend wrote as
configured, `status --all` sent a request with a bearer from the file
to a URL from the file, `status`, `dump` and `auth list` copied its
keys into the profile's auth.json, and HERMES_REDACT_SECRETS was taken
from it.
Now, for a home that is marked:
- tools.hosted_tool_policy: the four host features that start a process
from the profile's files (RUNS_PROFILE_COMMANDS: shell_hooks,
mcp_stdio, cron_scripts, skill_inline_shell) are off, at the place
each already asks whether it may run in a hosted scope, and
host_feature_refusal() answers with the run-elsewhere message. The
one subprocess site of shell hooks starts nothing (`hooks test`,
`hooks doctor`, a hook registered before the profile was marked), and
the MCP stdio transport starts nothing, whoever asks.
- The MCP probe (_probe_single_server: `mcp test`, `mcp add`,
`mcp configure`, `doctor`, the dashboard and TUI routes) raises
ProfileRunsElsewhere before it validates, resolves, starts or calls a
server, stdio or HTTP. `mcp login` and `mcp reauth` refuse first,
before they drop the stored tokens or the device flow calls the
entry's server.
- `hermes secrets <source> <verb>` exits 1 with the message of the
commands that run a turn (one wrapper where the verbs are registered).
- `hermes send` exits 1 the same way, before its own loader reads the
home's .env and config.yaml credentials into the process.
- agent.secret_scope.load_env_file(), the one .env tokenizer, reads a
file in a marked home as empty and does not open it. That covers
hermes_cli.config.load_env(), get_env_value(),
get_env_value_prefer_dotenv(), reload_env(), the credential pool's
seeding from .env, and the secret scope a multi-profile host builds
for a profile. Hermes's own .env writers (save_env_value,
remove_env_value) do not read through it and still write the file, so
a key the user saves through the marking plugin's host process lands
there. A file in any other folder (a plugin's host-only copy) reads as
before.
- `hermes status --all` does not probe LM Studio at model.base_url: with
the .env values out of reach, the address in config.yaml still sent a
request from the host.
- `hermes status` and `hermes config` print one line saying that the
profile's .env keys are not read on this host, because they now show
as not set.
The check behind the tokenizer and the features is
profiles_run_elsewhere.home_runs_elsewhere(home): the answer of
run_elsewhere_for_home, kept per process and home. Each call stats the
marker folder and the home's marker file, and asks again when that
differs from the stat taken before the last asking, so a marker written
or removed by any process is seen at the next call. A marker folder that
cannot be read marks every home, as it does for running a profile, and
is asked about again every time. A process that is denied the folder is
the backend the plugin runs: it reads its own .env and runs its own
hooks and MCP servers as before.
This corrects the previous commit's message, which said "Not covered:
hermes_cli.config.load_env() and the readers built on it (get_env_value,
reload_env) still open the .env file when asked, and the secret scope a
multi-profile host builds for a profile it serves still reads it". Both
are covered now.
Not covered: config.yaml of a marked home is still read (`hermes status`
and `hermes config` show it). `quick_commands` of type exec still run in
a chat client, gateway or TUI backend that was already running when the
profile was marked. resolve_home_dotenv() (two config migrations) still
parses the home's .env. Plugins in the home are still discovered.
* fix(profiles): no quick command runs for a profile that runs elsewhere
A quick_commands entry of type exec is a shell command in the profile's
config.yaml, a file the backend the plugin runs writes. The refusals so
far keep a hermes command from starting, on a marked home, a process
that dispatches one. Three cases still reached the three places that
start the command (the classic CLI, the gateway, the TUI / dashboard
backend):
- a chat client, gateway or backend that was already running as the
profile when it was marked: its turns are refused, its slash commands
were not;
- a dashboard or `hermes serve` backend on another profile's home, whose
command.dispatch takes the profile with the request (the `profile`
parameter, or a session of that profile);
- a multiplexing gateway: its own quick commands are the default
profile's whichever profile's process started it
(load_gateway_config_for_runner), so a gateway started from a named
profile while `default` is marked had them.
Each of the three places now asks run_elsewhere_refusal() before it
starts the command and answers with the run-elsewhere message instead.
The home asked is the one whose config.yaml names the command: the home
bound for the request in the TUI / dashboard backend and for a local
session of the gateway, the process's own in the classic CLI, and for a
gateway's messaging commands the home its config was loaded from
(_hm_quick_commands_home: the default profile's when it multiplexes).
Alias quick commands are unchanged, and so is the backend the plugin
runs, which does not see the marker.
* test(profiles): fire the marker race helper after the module's own look
`_between_look_and_change` runs an action right after the marker module's
next look at a profile's marker, to play the writer that gets in between a
look and a change. It patched `os.listdir`, `os.lstat` and `_read_entry`,
and fired as soon as a call for the marker returned.
The suite's home guard (`tests/home_io_guard.py`) wraps `os.lstat` too, and
resolves the path before it calls the real function. On POSIX
`os.path.realpath` lstats every component of the path through `os.lstat`,
so the helper saw the guard's own lstat of `<profile>.json` first and fired
inside the guard, before the module's lstat had run. In
`test_a_clear_that_found_no_marker_never_removes_one_published_after_it_looked`
the other plugin's marker was therefore already in place when
`clear_profile_run_elsewhere` looked, and the call raised `ValueError`
instead of returning False. On Windows `realpath` does not call `os.lstat`,
so the test passed there and failed on Linux only.
The three wrappers now share a depth counter and fire only when the
outermost patched call returns: a look made inside a look is part of it.
The action runs at the same point on both systems, after the module's own
look and before its change. No product code changes.
* fix(mcp): refuse "mcp add" first for a profile a plugin runs elsewhere
`hermes mcp add` reached the run-elsewhere refusal only inside its probe,
and treated it like any failed connection: it printed "Failed to connect"
and offered "Save config anyway", which wrote the server entry (disabled)
into the marked profile's config.yaml. For an HTTP server it had by then
asked for a bearer token and saved it to the profile's `.env`.
`cmd_mcp_add` now refuses before its first question, the way `send` and
the `secrets` verbs do: the message on stderr, exit 1, nothing asked and
no file of the profile changed.
The probe's other callers leave nothing written when the probe refuses
(`mcp test`, `mcp configure`, the dashboard and TUI test routes, the
connector install, the OAuth flows) and are unchanged.
* test(profiles): gate the Windows letter-case test with the platforms marker
`test_a_profiles_folder_spelled_in_another_letter_case_reads_the_marker_on_windows`
was gated with a bare `skipif(os.name != "nt")`. The Windows lane imports
only files that carry a `platforms(...)` spec covering Windows and selects
with `-m platforms`, so the test ran on no CI host (tests/AGENTS.md: "Use
the marker, never a bare `skipif`"). It now carries
`@pytest.mark.platforms("windows")`. No other test this branch adds gates
on the host with a `skipif`.
* docs(dashboard): say which requests _cron_profile_home() refuses
The helper's docstring said that the host "neither reads nor runs" a marked
profile's "jobs, sessions or files". The helper answers 409 only to the
requests that resolve their profile through it: every cron request (an omitted
profile resolves to the backend's own), and the session and file requests that
name the profile. A session or file request with no profile uses the backend's
own home without asking the helper, as the description's "Not covered" section
says. The docstring now says that. No code change.
Found in review.
* fix(profiles): ask again when a home's link leads to another profile
home_runs_elsewhere() keeps its answer per process and home path, and held it
valid while a stat of the marker files it had worked out was unchanged. Those
files belong to the directory the path led to at the first asking. When the
home is a symlink or junction and the link is pointed at another profile, no
marker is written or removed, so the kept answer stayed: pointed at a marked
profile, run_elsewhere_for_home() refused the home while load_env_file() still
read the marked profile's .env; pointed away from one, the unmarked home's
.env read as empty. Reproduced with a symlink on Linux and with a symlink and
a junction on Windows. A link above the home (the root itself) was already
seen, because the marker paths are read through it.
The kept answer is now also for the directory the path leads to: each call
stats the home and compares device and file id with the stat taken before the
home was resolved. That is one more stat per call. Measured for a plain home,
the cached check goes from 2.5 to 5.4 us on Linux and from 7.0 to 12.3 us on
Windows, and load_env_file() from 17 to 20 us and from 104 to 112 us; through
a link on Windows the check goes from 27 to 71 us. Resolving the home at every
call instead would add 23 us on Linux and 87 us on Windows, more than the
whole check.
Found in review.
* fix(profiles): a second name for a marked profile's home is not served either
Found in review. With profiles/alias a link to profiles/ops (a symlink, or a
junction on Windows), marking ops took only the name ops out of
profiles_to_serve(): the list was filtered by name, so the host gateway kept
alias in its served set, although every check that asks by home refused it.
Two more checks asked by name and let the link through: the Kanban
dispatcher's profile_exists_here(), and the dashboard's profile resolution
_cron_profile_home(), behind the cron, session, history and file requests
that name a profile.
All three now ask by home. The served list and the dispatcher use the kept
answer of home_runs_elsewhere(), which costs stats per profile instead of a
resolve and a folder listing; the dashboard asks run_elsewhere_for_home()
and answers 409 with the marked profile's name. The kept answers hold 4096
homes instead of 256, so a host with several hundred profiles still answers
its list from stats.
* fix(profiles): a clone made under a marked name keeps the keys it was cloned with
Found in review. Creating a profile mirrors the launch profile's .env into
it, but only over the seeded comment-only stub, never over the keys a clone
brought. That check asked the .env tokenizer what the new file holds, and
the tokenizer answers with nothing for a home a plugin runs elsewhere. A
profile cloned under a name whose marker was already there (left behind
when an earlier profile of that name was deleted) therefore looked empty,
and the launch profile's .env was copied over the cloned keys.
The check now reads the destination as the file it is
(load_env_file(..., for_overwrite_check=True)). Nothing else reads a marked
home's .env: every value reader still gets nothing from it. A new profile
whose .env is the stub still receives the launch keys, marked name or not,
as every new profile does.
* fix(profiles): a marker covers its profile's directory under every name
Found in review, as the mirror of the link case fixed before: with
profiles/ops a symlink or junction to profiles/real and ops marked, the
directory's own name real was still listed, served, built and run on this
host, and its .env was read. A home was followed to the profile its path
leads to, but not to the other names that lead to its directory, while the
backend elsewhere runs in that one directory whatever it is called.
run_elsewhere_for_home() and home_runs_elsewhere() are the two functions
every refusal asks. Both now also compare the home's directory (device and
file id) with the home of each profile the root's marker folder marks, so a
marked name that is itself a link marks the directory it leads to, under
that directory's own name too. An error or a filesystem without file ids is
never a match.
The kept answer of home_runs_elsewhere() adds one stat per other marked
profile, which also sees a marked link pointed at another directory. It
learns of a new marker under another name from the marker folder's time, so
a listing taken less than two seconds after the folder changed is not
relied on and is taken again at the next call, without resolving the home
again: two changes can share one tick of a filesystem's clock.
* fix(profiles): home maintenance waits while a plugin runs the profile elsewhere
After an installed revision changes, the first start of each profile runs
home maintenance for its own home (boot_bootstrap): the config migration,
which first copies config.yaml and .env beside themselves as
<name>.bak-<stamp>, the plugin-catalog cache drop, launcher publication and
the default-plugin check. Every hermes command and the gateway process make
that call before any command can refuse. A host start under a marked
profile, the marking plugin's own status and switch-off commands included,
therefore rewrote config.yaml under the backend the plugin runs and left a
byte copy of the keys file in a home that backend reads and writes.
run_boot_bootstrap now asks run_elsewhere_for_home() for this process's
home when maintenance is due (a new revision, or a step still owed), before
it takes the record lock. For a marked home it runs no step and writes no
record, so the maintenance stays owed and the first start after the marker
is gone does it. The question is asked by home: a marked home reached
through a link, and the directory behind a marked link, are covered. The
backend the plugin runs (it is denied the marker folder) and every unmarked
profile, the default one included, are maintained as before. A marker
folder that cannot be read holds maintenance back, as it refuses every
profile.
A start whose record says this revision is done reads its record and
returns as before; nothing is asked on that path.
One log line says why: "home maintenance: the '<plugin>' plugin runs
profile '<name>' elsewhere, so this host leaves its home alone; it is owed
until the profile runs here".
* fix(profiles): the backend migration does not move a profile a plugin runs elsewhere
`hermes gateway migrate --backends --apply` and the dashboard's "move to the
gateway" request (`POST /api/gateway/migrate/backends/apply?profile=`) went
ahead for a profile a plugin runs elsewhere. The move wrote `.env` and
`config.yaml` in that profile's home, installed and started a gateway service
for it and stopped its old backend. The gateway then refused to run the profile
and exited, so the run could only end in its rollback, which put the saved
`.env` and `config.yaml` back over whatever the backend the plugin runs had
written in the meantime.
The refusal a marked profile gets everywhere else is now one of the blockers
the apply path adds before anything changes. The command exits 3 with it, the
dry run and `GET /api/gateway/migrate/backends/plan` list it, and the
dashboard's request answers 409 and starts no run.
* fix(profiles): the config.yaml of a profile a plugin runs elsewhere sets no host environment variable
Importing `gateway.run` copies settings of the launch home's `config.yaml` into
the process environment. Among them is every top-level scalar of the file,
under the scalar's own name when that name is not set yet. `hermes -p <profile>
gateway status` imports the module, and so does the gateway process before it
refuses a marked profile. While a plugin runs the profile elsewhere, the
backend it runs writes that file, so it could choose `LD_PRELOAD`,
`NODE_OPTIONS`, `PYTHONPATH` or a proxy for that host process and for every
program the process starts afterwards. The home's `.env` was already closed for
this reason; `config.yaml` was a second way in.
`load_launch_home_dotenv()` in `env_loader.py` asks once whether a plugin runs
the launch profile elsewhere, runs the dotenv load with that answer
(`load_hermes_dotenv(home_elsewhere=...)`, the keyword the bootstraps already
take) and returns it. `gateway.run` calls it where it called
`load_hermes_dotenv`, and for a marked home it does not read the file for its
bridge. A home without a marker is asked about as often as before, and its
bridge is unchanged.
* fix(profiles): reading an env file under a folder named like ~user no longer raises
`load_env_file()` asks whether the file's folder is the home of a profile a
plugin runs elsewhere. That question expanded a leading `~name` with
`Path.expanduser()`, which raises `RuntimeError` when no user has that name.
So on Linux and macOS, with no marker anywhere, a relative path whose first
folder is named like `~someone` made the tokenizer raise ("Could not determine
home directory."), where it had always read the file as written or returned
`{}`. Windows guesses a folder for any `~name` and did not raise.
The marker question now expands with `os.path.expanduser()`, as its stat of the
home already did: a `~name` that is no user's stays as written, which is the
path the read opens.
* fix(profiles): the refusal says how to get a profile back when its plugin is gone
A marker can outlive the plugin that wrote it: the plugin was removed or
disabled, it no longer loads, or the Hermes root came back from a backup taken
while the profile ran elsewhere. The owner then meets the refusal at every
command that runs the profile, and its advice was to turn this off in a plugin
he no longer has. Core has no command that clears a marker, and the refusal
named neither the file nor another way.
The refusal for a marker that names its plugin keeps its sentences and ends
with one more: if that plugin is no longer installed or no longer loads,
deleting the marker file (named by its path) lets Hermes run the profile on
this computer again, and the file is not to be deleted while the plugin still
runs the profile. The user guide says the same.
* test(profiles): marking a profile leaves the marker folder listable by other local users
On Linux and macOS `mark_profile_run_elsewhere()` sets the marker folder to
0755. A host service that runs as another local user must be able to list the
folder: a listing that is denied reads as "this process is the backend the
plugin runs", and such a process refuses nothing. No test noticed when that
`chmod` was removed. This one marks under umask 077, and marks again after the
folder was made 0700, and expects 0755 both times.
* test(profiles): the quiet-folder test no longer depends on how fast it runs
`test_a_marker_folder_that_has_been_quiet_is_not_listed_again` expects 150
listings of the marker folder "a moment after the marker was written". The
module stops listing once the folder's time is two seconds old, so a test run
that stalls for two seconds between writing the marker and the end of that loop
counts fewer listings and fails. It did once on a loaded machine.
The test now stands the module's clock at the folder's own time before it asks
for the first time, as it already moved that clock forward for its second half.
* test(profiles): the marker question by home does not raise for a folder named like ~user
The dotenv load asks whether a plugin runs a home's profile elsewhere through
`run_elsewhere_for_home()`, which expanded a leading `~name` the way the
tokenizer's question did. The test of a folder named like a user that does not
exist now asks through both, so each of the two expansions has a test that
fails when it raises again.
* fix(profiles): the backend migration plans no step against a profile a plugin runs elsewhere
The block for a marked profile sat among the blockers of the apply path, which
a plan that can only be done by hand never reaches. On Windows every plan is of
that kind, and there the backend a plugin runs is a process of this host
(`hermes serve --isolated` under the profile's home). So `hermes gateway
migrate --backends --apply`, with or without `--dry-run`, found that process as
an old backend of the marked home, exited 6 and printed the steps of a move by
hand: `taskkill /PID <its pid> /T /F`, then installing a gateway for the
profile.
The refusal is now the first answer of the plan's own owner check, which every
form of the plan passes before a step is chosen. A marked home gets a blocked
plan (exit 3) with the run-elsewhere message and no step, on every platform;
the dashboard's plan and apply routes read the same plan.
* test(profiles): the public marker functions are pinned by what the validator does
`test_the_user_guides_marker_example_validates_clean` read the user guide from
the repository, cut its Python example out, parsed it and compared the names
it imports with a list. That is a test of a file's text. What it guarded is
that `hermes plugins validate` calls the three documented marker functions
public, and `test_the_documented_marker_functions_are_public_plugin_api`
already pins that by running the validator on a plugin that imports them:
with one of the three taken out of the public list, that test fails.
The guide-reading test is removed. The other tests of this branch read only
files under their own temporary homes.
* fix(profiles): no form of the backend migration acts on a profile a plugin runs elsewhere
The block for a marked profile sat in the migration's plan, and several
forms of `hermes gateway migrate --backends` never reach the plan or act
before it:
- `--apply --detach` started the run in the background and reported it as
started; only that run then refused.
- `--restore` undid a move that was made before the profile was marked: it
stopped and removed the gateway service, wrote `config.yaml` and `.env`
back from the move's backups and started the old backend.
- A move that did not finish was rolled back the same way by the next
`--apply` or `--restore`, and the dry run named the command that does it.
- A second `--apply` on a moved home named `--restore`.
- Every form but the dry run made the run lock in the marked home first.
The command now refuses where every form enters: for a marked profile
`--apply` and `--restore`, with any other flag, exit 3 with the
run-elsewhere message before the home's record is read or its lock is made.
Nothing is written, started or stopped, and the record of an earlier move
stays for when the profile runs on this host again. `--status` still reads.
The dashboard's `POST /api/gateway/migrate/backends/apply` and
`.../restore` answer 409 `blocked` with the same message for a marked
profile, start no run and name no command.
* fix(profiles): the lists of old backends say when a plugin runs the profile elsewhere
The backend a plugin runs for a profile can be a `hermes serve` process of
this machine, which the backend migration's scan finds like any other old
backend of that home:
- `hermes gateway migrate --backends` listed it without a word about the
plugin and ended with the line that offers the dry run of its move.
- After `hermes update`, the notice called it "an old Hermes backend for
this profile" and offered the same dry run.
- The rows the dashboard's plan route returns said nothing about it either.
A listed backend whose home's profile a plugin runs elsewhere now carries
one more note, in the report's text and JSON and in the dashboard's rows:
"Profile 'ops' runs elsewhere (the 'x' plugin runs its backend): Hermes
does not move this backend to the gateway on this host." The report offers
no dry run when its own profile is marked, and the update prints no notice
for such a profile. The move itself is already refused for it.
* fix(profiles): the blocked plan of a profile a plugin runs elsewhere lists no backend to move by hand
Where a backend can only be moved by hand (on Windows every one), the plan
of a marked profile printed no step but kept the entry above the blocker:
"manual cannot be migrated automatically ... Run the steps below in
PowerShell or Command Prompt ... Steps, in this order", with nothing under
it. The dashboard's card prints "This server cannot be moved from here" and
those instructions for every such entry.
The marker's check is now its own step of the plan, before the checks of
which gateway serves the home, and the plan it blocks lists no backend at
all: the text is the home and the blocker, and the JSON has an empty
`unsupported`. The other reasons a plan is blocked print as before.
* fix(profiles): the refusal's last sentence says "on this host" like the sentences before it
The sentence the refusal gained for a plugin that is gone said that deleting
the marker file "lets Hermes run the profile on this computer again", two
sentences after "Hermes does not run it on this host". The message and the
user guide say "host" everywhere else, so this sentence does too.
* test(profiles): the line for a listed backend says what the marker tells
The line a listed backend of a marked home carries has three forms: the
plugin by name, "a plugin" when the marker file cannot be read, and "Hermes
cannot read <folder>" when the marker folder cannot be read. The tests of
the report covered the first. This one reads all three from real markers.
* fix(ci): a change to the run-elsewhere marker module starts the update suite
The notice `hermes update` prints about an old backend
(hermes_cli/update_backend_notice.py) now asks whether a plugin runs the
profile elsewhere, so it imports hermes_cli/profiles_run_elsewhere.py. The
change classifier did not route that module to the upgrade E2E lane, and
tests/ci/test_update_ci_routing.py failed for it:
e2e_upgrade: imported by the update path but not routed to it:
{'hermes_cli/profiles_run_elsewhere.py': ['hermes_cli/update_backend_notice.py']}
The module joins the lane's owner list, beside the backend-migration marker
the same notice reads.
* fix(profiles): a marked profile's key_cmd is not run on this host
`providers.<id>.key_cmd`, and a custom provider's `key_cmd`, is a shell
command line in the profile's own `config.yaml`. Hermes runs it to get the
provider's key, with the profile's environment and credentials. For a
profile a plugin runs elsewhere, the backend there writes that file, and
nothing on this path asked the marker: the dashboard's
`GET /api/model/options?profile=<name>` ran a marked profile's command once,
as it does for any profile.
`_mint`, the one place every `key_cmd` runs, now raises `CommandTokenError`
with the run-elsewhere message for a marked profile. The model picker turns
that error into a probe without a key, so it still answers; the same request
now runs the command zero times.
The fix and its test are the reviewer's patch from the review of
6a60a75a669, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): a dashboard file request never dials a marked profile's SSH workspace
A file request that names a profile is answered 409 when a plugin runs that
profile elsewhere. For a profile whose workspace is on an SSH host the
request went another way first: `_fs_backend` read `terminal` from the
profile's `config.yaml` and dialed the host named there before the route
reached the refusal. `GET /api/fs/list?profile=<name>` and
`GET /api/fs/default-cwd?profile=<name>` dialed the host a marked profile's
config names.
`_fs_backend` now resolves the profile first, which answers 409 for a marked
one before its config is read. Every file route that can go to an SSH host
passes through it. A request that names no profile behaves as before. Two
existing tests call the real `_fs_backend` with a profile that is not on
disk; they now stand in for the lookup.
The fix and its tests are the reviewer's patch from the review of
6a60a75a669, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): gateway ensure and attach refuse a marked profile whose directory is a link out of the root
A marker covers the profile's directory whatever path leads to it. But
`ensure_gateway_runtime` made the home canonical before it asked the marker.
When `profiles/ops` is a link to a directory outside the Hermes root, the
canonical path has no Hermes root above it and so no marker: `gateway ensure`
went on to discovery for a marked profile and did not answer
`profile_runs_elsewhere`. `attach_gateway` resolves the home before it calls
`ensure`, so it went the same way.
Both now ask about the home as it was given too. In `ensure` the check sits
inside the existing assignment, which keeps the function at the complexity
cap; `attach_gateway` checks before it resolves. The answer for a marked
profile is the one `ensure` already gave: `inaccessible`,
`profile_runs_elsewhere`, the refusal in `detail`.
The fix and its test are the reviewer's patch from the review of
6a60a75a669, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): marked profiles still count when an external cron registry may be shared
An external cron provider keeps one remote registry that is not scoped to a
profile, so Hermes uses it only on a host with a single profile. Two callers
decide that by counting the served profiles, and a profile a plugin runs
elsewhere is no longer in that list:
- The gateway chose its scheduler with the number of profiles it ticks. On a
host with `default` and a marked `ops` that number is 1, so the gateway
kept the external provider, which reconciles the registry toward
`default`'s jobs when it starts.
- The dashboard skips an external reconcile when it counts more than one
profile. With the other profiles marked, the reconcile ran.
On main both counts included `ops`. If the backend elsewhere arms that
profile's jobs through the same provider account, such a reconcile can
cancel them.
Both callers now count the marked profiles where the question is who may
share the registry. The profiles the gateway ticks and the dashboard lists
are unchanged. Three existing stand-ins for `_cron_profile_dicts` accept the
new keyword.
The fix and its tests are the reviewer's patch from the review of
6a60a75a669, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): a marked profile's speech command is not run on this host
`tts.providers.<name>.command` and `stt.providers.<name>.command` are shell
command lines in the profile's own `config.yaml`, and one runner starts
both. The dashboard reaches it for a named profile without building an
agent: `POST /api/audio/speak?profile=<name>` ran a marked profile's TTS
command, and `POST /api/audio/transcribe?profile=<name>` ran its STT command
and returned what it printed. The backend a plugin runs elsewhere writes
that file, so this is the host starting a command line that backend wrote,
as with a provider's `key_cmd`.
`run_command_provider`, the one place both kinds run, now raises
`RuntimeError` with the run-elsewhere message for a marked profile. The
callers already turn a `RuntimeError` of the runner into their own failure
answer, so the speak request answers 400 with the message and the
transcribe request answers that the transcription failed.
* fix(profiles): the gateway's clients ask about a linked profile's home before they resolve it
`gateway ensure` and `gateway attach` now ask the marker about the home as
it was given. Two callers resolve the home before those functions see it,
so a marked profile whose directory is a link out of the Hermes root still
got past them:
- `connect_gateway`, which `hermes sessions discard` and `adopt` and the
cron and Kanban clients call. None of them passes the command line's own
refusal first, and for such a profile it went on to discovery and could
start a gateway.
- The TUI's bootstrap script, which an open TUI runs again whenever its
gateway is gone. A TUI that was open before a plugin took the profile
over started a gateway for it again.
`connect_gateway` asks about this process's home before it resolves it and
raises the error it already raises for a gateway it may not attach to
(`inaccessible`, `profile_runs_elsewhere`). The bootstrap script passes the
home to `attach_gateway` as the environment names it; `attach_gateway`
resolves it after its own check.
* fix(profiles): the plugin host takes no launcher and no package from a marked profile's home
With `plugins.isolation: host` every plugin of the profile loads in a child
process. Its command line began with `plugins.host.launcher` from the
profile's own `config.yaml`, and the child started in the profile home with
that folder first on its import path. For a profile a plugin runs elsewhere
the backend there writes both: `hermes -p <name> status` started the launcher
that file named, and a `hermes_cli` package placed in the home ran in the
child instead of Hermes's own.
For a marked profile `host_launcher()` now reads the launcher from the
managed overlay only, which that backend cannot write; with none set there,
the child starts without a launcher. The child is started with `-P`, as the
profile extraction already was, so the folder it starts in is no longer on
its import path. That part applies to every profile: a module that sits in
the profile home can no longer be imported by name from a hosted plugin.
Hermes's own packages still come from `PYTHONPATH`, and a plugin's own
package is loaded by its path as before.
The fix and its tests are the reviewer's patch from the review of
cd58d712aa6, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): a marked profile's password manager binary is not run on this host
`vault.bitwarden.binary_path` and `vault.onepassword.binary_path` name a
password manager's command line program in the profile's own `config.yaml`.
The Settings dialog's `vault.unlock` request hands that program the master
password the person typed, without building an agent. For a profile a plugin
runs elsewhere the backend there writes that file, and nothing on this path
asked the marker: the request ran a marked profile's program and gave it the
password.
`_bw` and `_op`, the one place each manager's program is looked up for
unlock, list and fill, now raise `RuntimeError` with the run-elsewhere
message for a marked profile. `vault.unlock` answers with its usual error
5095 carrying that message. The local vault does not pass either function.
The fix and its test are the reviewer's patch from the review of
cd58d712aa6, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): a marked profile's browser executable is not started on this host
`browser.executable_path` names the Chromium a local browser session starts,
in the profile's own `config.yaml`. `hermes doctor --live` launches it to
check that a browser can start, without building an agent. For a profile a
plugin runs elsewhere the backend there writes that file, and nothing on this
path asked the marker: `hermes -p <name> doctor --live` started the program a
marked profile named.
`launch_chromium`, the one place a local Chromium is started, now returns its
usual `(None, error)` with the run-elsewhere message for a marked profile.
`doctor --live` reports the browser probe as failed with that message.
The fix and its test are the reviewer's patch from the review of
cd58d712aa6, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): the cron registry count sees a marked default beside a standalone gateway
Whether an external cron provider's registry may be shared was decided from
the larger of two counts: the profiles the gateway ticks and the installed
ones. A gateway that runs as a standalone profile ticks only itself, and the
installed list leaves a standalone profile out. With `default` marked and the
gateway running as a standalone `ops`, both counts were 1, so the gateway
took the external provider and reconciled its registry toward `ops`'s jobs
alone, although the marked `default`'s backend may arm jobs there too.
The count is now the number of different profile names in the two lists
together. With no marker every profile in the installed list is one the
gateway ticks, so the count is the number of profiles it ticks, as before.
The fix and its test case are the reviewer's patch from the review of
cd58d712aa6, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): a managed launcher expands its env refs for a marked profile too
For a profile a plugin runs elsewhere the plugin host's launcher is read
from the managed overlay alone. That read took the overlay's file as
parsed, so a ${VAR} in plugins.host.launcher reached the child's command
line unexpanded, while every other profile got the expanded value.
host_launcher() now asks apply_managed_overlay({}), which expands refs
against the process env the way the config loader does.
* fix(profiles): a marked profile linked out of the root does not get its own launcher
`hermes -p ops` names the home `<root>/profiles/ops`. When that is a link
to a directory outside the Hermes root, the plugin manager is keyed by the
directory the link leads to, and the plugin host asked the marker about
that directory, which has no marker folder above it. So the host child of
such a profile still started under the `plugins.host.launcher` its own
`config.yaml` names.
The manager now keeps the home as it was named (`owner_home`), and the
host passes it to `host_launcher()`, which asks the marker about that
home. Other callers of `host_launcher()` are unchanged.
The fix and its test are the reviewer's patch from the review of
b3d3693bb6a, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): an empty PYTHONPATH entry does not put the profile home on the host's path
The plugin host's child starts in the profile home, with `-P` so that
folder is not on its import path. `-P` drops only Python's own first
entry: an empty entry in `PYTHONPATH` (`PYTHONPATH=:/x`, or a trailing
separator) still means the current directory, and the child inherited
such entries as they were. A module placed in the profile home then ran
in the host child again, ahead of the standard library.
The inherited entries are now made absolute against the parent's working
directory before the child gets them, so an empty or relative entry means
for the child what it means for the parent. This applies to every
profile, like `-P` itself.
The fix and its test are the reviewer's patch from the review of
b3d3693bb6a, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
---------
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
|
||
|
|
360f48814c |
refactor: callers find the install folder through project_root_str()
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. |
||
|
|
eef9a3e52c |
fix(plugins): a task left from an unloaded plugin load cannot publish after a reload
Under plugins.isolation: host, discover_and_load(force=True) (reload-plugins, and every plugin install, enable or update) loads a plugin again into the same host process under the same plugin_key. A task the first load spawned kept running, and its emit_plugin_session_event was taken for the new load and published to the session's viewers. - Hermes numbers each load of a plugin in the host (load), sends it with the load request, and forgets it at unload. - The host binds that load, with the plugin, to each request it serves, so it follows the request's code onto the tasks it spawns; session_event carries it. - The gateway process publishes only when that load is the plugin's current one; otherwise it logs and returns False, as the hosted call did before this PR forwarded it. A category plugin's fresh instance keeps its key's load. - ctx.emit_to_session reads the manager's home_path directly: every manager sets it, as the other readers of the plugin's own profile assume. Suggested by @BearHuddleston in review. - The late-event test now covers a same-host reload and waits with tests.waiting.wait_until and Events instead of sleep loops. ctx.emit_to_session from such a task is unchanged (it reached viewers on main too). Refs #142005, #141982 |
||
|
|
5f8968bd76 |
fix(plugins): a hosted session event goes out only as the live plugin sending it
Under plugins.isolation: host, the forwarded emit_plugin_session_event took the plugin_id the caller passed: a hosted plugin could publish as another plugin id, and a task it left running kept publishing after it unloaded. - The host process records which plugin's code each request it serves runs (the plugin_key of a load/unload, the owner of an invoked reference) and sends that with session_event. - The gateway process looks that plugin up among the loaded ones and publishes only when plugin_id is its own; otherwise it logs and returns False, as the hosted call did before it was forwarded. - In-process, emit_plugin_session_event still takes plugin_id as given. - Contract and guide wording: without plugin-rpc-v1, clients must not assume plugin RPC is supported. Refs #142005, #141982 |
||
|
|
be3d288fa0 |
fix(gateway): plugin RPC is a detectable contract member and session events work hosted
A client could not tell "no such plugin method" from "this server has no
plugin RPC": runtime.describe advertised nothing, and plugin.* was in no
contract or ledger. Under plugins.isolation: host the module-level
emit_plugin_session_event returned False and sent nothing, and an
in-process ctx.emit_to_session from a plugin's own thread on a multiplexed
gateway looked the session up in the launch profile.
- runtime.describe lists plugin-rpc-v1.
- tui_gateway/contracts gains CANONICAL_NAMESPACES (canonical_namespace):
plugin.{plugin_id}.{name} with open params, rendered as
CanonicalRpcNamespaces in the TS contract and x-canonical-namespaces in
OpenRPC; the serve handler ledger gets one row for it.
- The plugin host forwards emit_plugin_session_event to the gateway process
(host->parent request session_event), looked up in the host's profile.
- ctx.emit_to_session binds the plugin manager's home before the lookup.
Refs #142005, #141982
|
||
|
|
7e8c8a5856 |
fix(plugins): keep a reloaded hosted plugin when an abandoned load fails late
A hosted load abandoned at its load deadline can fail after a reload of the same plugin succeeded. Its failure cleanup unloaded the plugin key, which tore down the live load: its tools failed with "plugin host callable was released" and its on_unload had already run. Claim the plugin key before the host start can block, and run the failure cleanup only while this load still owns the key. |
||
|
|
f23fb505e7 |
fix(plugins): keep a failed hosted load's error when its cleanup fails
The failed-load cleanup added in the previous commit could raise before the original exception was re-raised, so the plugin's recorded error became the cleanup's (an on_unload that raised SystemExit, or one that exited the host). Run the cleanup best-effort, log its failure, and re-raise the register() error. |
||
|
|
994e901730 |
fix(plugins): run a failed hosted load's on_unload cleanup
Under plugins.isolation: host, a plugin whose register() queued an ctx.on_unload callback and then raised kept that callback (and any objects it handed over) in the plugin host. The in-process loader runs the callback when register() fails, so a hosted plugin that started a thread or opened a resource before failing leaked it until the host exited, and a later successful load inherited the stale callback. PluginHost.load now unloads the plugin key in the host when the load fails, which runs the queued callbacks and drops the host-side references, matching the in-process failure path. |
||
|
|
99cf3a6358 |
fix(providers): seed_pool_credentials takes plain values; hosted ambient tokens reach the host
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. |
||
|
|
808eaf32f9 |
fix(plugins): hosted providers keep their declared types across the plugin-host wire
Under plugins.isolation: host every value crosses as JSON, so a dataclass
arrived as a generic Record, a Path as str, an enum as its value and a
plugin object as an Opaque placeholder. Core consumers that type-check
broke:
- secret sources: SecretSource.fetch() came back as Record, the
orchestrator rejected it ("fetch returned Record instead of
FetchResult") and applied no secrets; fetch() also received home_path
as str, so `home_path / "x"` raised in the plugin.
- context references: ContextCompletionItem (a __slots__ class) became
Opaque, so @prefix: autocomplete silently returned nothing.
- context engines: clone_for_agent() returned Opaque, so no agent could
get its own copy of a hosted engine.
The provider ABC's annotations are the contract, so the wire now
restores against them: the parent rebuilds results from the declared
return type (dataclasses, enums, Paths, typed containers; a declared
provider ABC becomes an object proxy) and the host rebuilds method
arguments from the declared parameter types. Type names never come from
the host. ContextCompletionItem becomes a slots dataclass so it crosses
as data.
|