153073d9be2fcbabbd64213e3003ced284e4cb7e
1482 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
5829608b49 |
refactor(providers): combine gemini and solstice into bundled google plugin with native adapter
Moves `plugins/model-providers/gemini/`, `plugins/model-providers/solstice/`, and the three core Gemini adapter modules (`agent/gemini_native_adapter.py`, `agent/gemini_schema.py`, `agent/gemini_long_decode.py`) into one bundled `plugins/model-providers/google/` package: - `google/__init__.py` registers `gemini` then `solstice` directly (import-light; keeps transport modules lazy and ensures repeated `bundled_profiles()` passes register both). - `account_client.py` imports the sibling Interactions wire and native adapter directly, removing runtime cross-plugin discovery (`interactions_wire()` / `gemini_plugin_module()`). - `solstice` keeps its exact picker/registry positions (`picker_after="router"`, `registry_after="router.com"`). - Every core import inside `plugins/model-providers/google/` uses the published plugin API (`private_import_findings` = 0; boundary-lint baseline drops 33 private crossings). - Adds `tests/providers/test_google_cutover_surface.py` AST guard preventing core from re-importing the moved adapter modules. |
||
|
|
231617ea5a | refactor(gemini): extract neutral model-family, URL, and output-budget timeout helpers | ||
|
|
6d18eb30a2 |
refactor(plugins): name the producer of a Hermes-started turn instead of a boolean
turn_internal() read execution trust, so a restart's resume of a person's interrupted turn, automations, plugin injections and Bot Chat deliveries all looked Hermes-started. Replace it with turn_origin() (and ctx.turn_origin()), which names the producer only where Hermes knows it: - "process_notification": a background process's completion, watch match or liveness tick (_inject_watch_notification). - "delegation_result": an async delegation's result re-entering its parent. Every other turn reads None. The producer sets the origin on its event; the committed automation row records it as turn_origin and restore reads it back, so a row without one (any other producer, or one an older build queued) restores as None and its fingerprint is unchanged. A late steer or interrupt text run as the next turn reads None. The started_by_hermes bookkeeping in the Bot Chat and API admission paths is removed. Trust, authorization, allow_gateway_control and model-facing text are unchanged. |
||
|
|
e8b16ba90c |
feat(plugins): tell plugins whether Hermes started the running turn
turn_client() is None both for a turn Hermes started itself (a background-process notification, a delegation result, an automation wake) and for a person's turn sent over a connection that announced no client, so a plugin cannot tell a wake from a typed message by it. hermes_cli.plugin_session.turn_internal() (also ctx.turn_internal(), which answers through the gateway under plugins.isolation: host) reads the running turn's own event: True when Hermes produced its input, False for a message someone sent (typed in a client, announced or not, on a messaging chat, or an API request), None outside a turn, in a delegated child, in a managed worker, in a plugin's own slash command and for a synthetic turn Hermes does not mark internal (a goal continuation). An API turn is marked internal for trust when it executes, so admission now records what the event was before that mark; an API event with no record reads None rather than True. It only reads the turn context at hook time: no system prompt, tool list, message or model request changes. |
||
|
|
e993550e14 |
fix(desktop): show the per-profile approvals hint only in workspaces that declare it
The hint replaced the approval menu in every `plugin-workspace:` pane, so a single-bot Screen tab or a third-party plugin workspace lost the active profile's menu and got group-room copy. `host.openWorkspace` now takes `approvalScope: 'per-profile'`, which the group room sets; other workspaces keep the menu as before. The options type moves to `contrib/types.ts` (re-exported as `PluginWorkspaceOptions`), which keeps `sdk/index.ts` under its line cap. A preview fronting the room's group keeps the room's scope instead of falling back to the active profile's editable menu. The vitest case now runs with an open gateway, so it also pins that the mode read is skipped in the room and runs once on return. |
||
|
|
33522e6dee |
Merge pull request #159835 from NousResearch/fix/mac-dmg-sign-notarize
Some checks failed
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
Docs Search Monitor / probe (push) Has been cancelled
fix(desktop): sign, notarize, staple, and verify outer macOS DMG |
||
|
|
64e8f5bdde |
fix(gateway): record host memory pressure when the liveness watchdog kills the gateway
On a memory-starved Linux host the loop-liveness watchdog restart-loops the
gateway (exit 75, supervisor restart) and every kill reads as a plain
loop_liveness_watchdog exit. Nothing records that the host was out of memory,
and the reason does not even survive the restart: the next boot treats the
exited sentinel as clean and overwrites it.
At fire time the watchdog first logs its CRITICAL kill line, then takes a
fresh procfs memory sample (the heartbeat's copy is written by the wedged
loop, so it is stale by at least the strike window) plus Linux PSI from
/proc/pressure/{memory,io}, classifies it with classify_pressure, and adds
mem, psi and host_memory_pressure to the dump header. When pressure is
critical it logs one ERROR line naming MemAvailable/MemTotal, the gateway's
own RSS and PSI memory full avg10, and warns that a restart frees only the
gateway's own memory.
All of the kill's forensics (the CRITICAL line, the memory sample, the dump to
file and stderr, the sentinel stamp and a bounded log-queue drain) now run in
one daemon worker that the watchdog thread waits on for at most 5 s before it
hard-exits itself; inside it the memory sample gets at most 2 s. A Python-level
stall (a log handler blocked on a full stderr pipe, a stalled disk) or a
thread that cannot even be built costs the forensics, not the exit; before
this, a wedged handler on the kill path left the gateway alive indefinitely.
The faulthandler stack dump is C code that holds the GIL while it writes, so a
blocking write there can still hold the process; that predates this change.
A late stop() stands the watchdog down if it lands before the worker's commit
point, right after the dump; one lock makes that decision, so the watchdog
never stands down after the worker has committed to the exit. The watchdog
takes that lock with a 0.1 s timeout and exits if it cannot decide. The stamp is
written before the drain, so a slow drain cannot cost the next boot its
verdict. The liveness path now drains the async log queue (bounded to 1 s)
before os._exit through the same helper as the shutdown-watchdog path, so
queued lines are delivered best-effort. The hard exit reaps foreground
children only when that registry is already imported, so the kill path never
does a first import on a thrashing host. When it is loaded, that cleanup can
still wait on its own lock; that predates this change.
The verdict is stamped on the lifecycle sentinel as host_memory_pressure
(exit_reason is unchanged, so retained-state and operator wording keep
working). On the next boot, record_startup carries a watchdog exit forward as
prior_exit_reason / prior_host_memory_pressure and appends a
gateway.previous_watchdog_exit record to gateway-exit-diag.log; graceful exits
and the unclean-death path are unchanged. collect_memory_status reports
last_boot_watchdog_exit (either watchdog: liveness or shutdown) and
last_boot_memory_starved, which /api/status passes through as-is; the
dashboard docs list both fields.
The kernel OOM killer is the case none of this sees: an OOM kill is a
SIGKILL, so no exit path runs and the next boot only had the heartbeat
heuristic (suspected_oom). The 30 s heartbeat now also stores the kernel's
OOM-kill counters (sample_oom_kills: boot_id, oom_kill from /proc/vmstat, and
oom_kill from the gateway's own cgroup v2 memory.events with that cgroup's
inode; the cgroup path comes from cgroup_cleanup's existing reader, resolved
once per process). After an unclean death the next boot compares them with
the current counters and records oom_kill_seen with oom_kill_scope "cgroup"
or "host" when one grew. Growth only shows that the kernel OOM-killed some
process in that scope during the window, not which one: a tool subprocess in
the same cgroup counts, and host scope counts any process on the machine.
The cgroup counter is used when the cgroup is still the same one; otherwise
the host counter is used. A systemd unit or container restart recreates the
cgroup with its counter at 0, so after a supervisor restart the comparison is
usually host-scoped; cgroup scope applies only when the gateway restarts
inside a surviving cgroup. The comparison is made only when the heartbeat
belongs to the life the sentinel describes (same pid, written after that
life's claim) and is at most 15 minutes old; a different boot, an older
life's heartbeat, a longer gap or missing data makes no claim. The enrichment
runs in its own guard, and a non-UTF-8 cgroup path is decoded with
surrogateescape, so a reader failure can never cost the unclean-exit verdict.
record_startup carries it as prior_oom_kill_seen / prior_oom_kill_scope, the
unclean-exit WARNING line and exit-diag record include it, and
collect_memory_status reports last_boot_oom_kill (null, "cgroup" or "host").
The existing opt-in monitoring export gains two gauges read from the same
ledger and heartbeat files: hermes.gateway.previous_exit (one closed-set
attribute, strongest first: oom_kill_cgroup, watchdog_memory_starved,
watchdog, oom_kill_host, suspected_oom, unclean, none, or unknown; host-scope
activity ranks below the watchdog's own verdict, and none means no adverse
evidence recorded, a first boot included) and hermes.gateway.memory_pressure
(ok, elevated, critical, unknown). They are registered with the metric
provider, ride the snapshot's base attributes, and a failing reader logs a
WARNING naming only the exception type. Every gauge callback rebuilds the
snapshot, so the reader's result is reused for 1 s. No config key or channel
is added. Nothing is exported when a watchdog fires: the process hard-exits
right after and the emitter is asynchronous, so the next boot's gauge carries
the verdict instead.
Restart backoff after repeated starvation kills is left to a follow-up.
Refs #148527
|
||
|
|
949afabbe7 |
Merge pull request #159469 from NousResearch/feat/stable-mac-dmg-url
feat(release): publish stable macOS DMG alias and downloads page on promotion |
||
|
|
16fd059ad8 |
feat(plugins): publish the Gemini thinking helpers for provider plugins
A provider plugin on the native Gemini wire (generateContent) has no published way to map a Hermes reasoning config onto thinkingConfig: the mapping lives in private core helpers, so a plugin either re-implements the per-model rules or imports internals the boundary lint rejects. The Solstice provider plugin needs this seam. Publish three helpers in agent.reasoning_effort under a new plugin_api.json group, document them in the model-provider guide and regenerate public-api.md: - gemini_thinking_config(model, reasoning_config): the shared Gemini thinkingConfig mapping plus the xhigh lift, keyed on the id the native client sends. - bare_gemini_model_id(model): the native client's prefix rule (gemini/ and google/ stripped), moved verbatim from agent.gemini_native_adapter into this import-light module; the adapter imports it back, so its existing name keeps working. - clamp_effort (already in the module). The gemini and vertex profiles are unchanged. test_reasoning_effort_plugin_api.py checks the helper against the gemini profile's own output across models and efforts (prefixed ids included), the prefix rule, the adapter's import name, and that importing the module loads no HTTP stack. |
||
|
|
feceed663e | fix(cron): keep plugin lookups within one profile | ||
|
|
bbdc728912 |
docs(plugins): note off-chain fallback in store.lineage.lineage guide paragraph
Clarify in website/docs/developer-guide/plugins/index.md that [0] of store.lineage.lineage(session_id) is the first id of the returned chain (not necessarily the original session) and that (session_id,) is also returned for a session with no compression chain or a session outside the oldest-continuation chain the lookup follows (such as a later sibling continuation), alongside fork children and tool-sourced runs. Pin the branch-fork and off-chain sibling cases in test_the_plugin_guides_lineage_read_gives_the_root_first_on_a_read_only_handle. |
||
|
|
a5a7a0784d |
fix(cron): use firing job settings in delivery_platforms and expose ctx.cron_delivery_platforms
Capture a delivery-relevant snapshot of the firing job inside cron.execution_identity.enter_cron_execution so delivery_platforms() with job_id=None answers from the run that is actually firing even when the saved job is edited or deleted mid-run, while explicit job_id lookups remain previews of the stored job. Add PluginContext.cron_delivery_platforms(job_id=None) (and tuple preservation in RemotePluginContext) so hooks running under plugins.isolation: host read the firing run's delivery platforms in the gateway in the calling hook's context. Re-export CronSchedulerRegistrationError from cron.plugin_api so plugins can catch it without a private core import, and update the plugin guide example and tests accordingly. Addresses Greptile review feedback on PR #159657. |
||
|
|
1dd65c2587 |
docs(plugins): the lineage read returns only its own id for a tool session
The guide said `[0]` of `store.lineage.lineage(session_id)` is the session the conversation started in. The read treats every `tool` session and every fork child as a fork, so a `tool` run that continued after compression returns only its own id. The paragraph now says what the first id is and lists those cases, and the test pins the `tool` one. |
||
|
|
030a6c439e |
fix(cron): cron.plugin_api reads home one way and reports a failed registration one way
- `home` was expanded for `~` only, while core's profile bind also expands environment variables. For a directory whose path holds a literal `$NAME` with NAME set, the job was stored in the literal directory while its settings (time zone) were read from the expanded one, which the bind also created. `home` is now read the way Hermes reads a home path, once, for the existence check, the bind and the cron store. - A failed registration raised `CronSchedulerRegistrationError` for a new job but the provider's raw error for a job that already existed, so a second attempt against an unreachable provider raised a different type. Both now raise `CronSchedulerRegistrationError` carrying the saved job. - Docs: `delivery_platforms` answers for the normal delivery lane; a `failure_deliver` override is not consulted. |
||
|
|
2161193c21 |
docs(plugins): silence helpers are text checks; tool and oneshot are launch labels
- adding-platform-adapters.md: the three published silence helpers recognize and strip markers. Whether a turn may stay silent is the gateway's decision, and where a reply is expected it can send a notice in place of a bare marker, so an adapter must not use them to drop text it is handed to send. The test is renamed to match. - session_source(): `tool` is the label a third-party integration launches with and `oneshot` a finite `chat -q` / `-z` run. The label says how a session was launched, not that a person is waiting. - fork_origin(): the skill curator's own agent runs under the `background_review` label too. |
||
|
|
5159f3be0d |
fix(cron): ensure_named_job reads the name from the job store, and the guide names the running job through ctx
`ensure_named_job` looked the name up with `list_jobs`, which also reads every job's latest and live run from the executions ledger and adds `latest_execution` / `live_execution` to each record. So an existing job came back with two keys a newly created job does not have, and every call paid for a ledger read it never used. The lookup now reads the job store and returns the same record shape either way. Docs for `delivery_platforms`: - With no job id it answers for the cron run bound in the calling process. A hook of a plugin running in a plugin host has no run bound there, so the guide and its example now name the job with `ctx.current_cron_execution().job_id`, which answers in both modes. - The answer is the stored job's: an edit saved while a run is in flight shows up, though that run delivers with the settings it started with. - `home` naming the process's own profile runs no external secret source; only another profile's first call does. |
||
|
|
92f61fa16d |
docs(plugins): name the storage-interface read that replaces get_compression_lineage
The old session store's `get_compression_lineage(session_id)` is not one of the methods the `hermes_state` stand-in carries, and the migration guide did not say what replaces it. A plugin that needs the session a conversation started in (for example to match a prompt to a chat after a compression) reads `store.lineage.lineage(session_id)` on the handle: the lineage's ids, root first, `(session_id,)` for a session that was never compressed and `()` for an unknown id. It works on a read-only handle. The guide now says so, and a test reads a three-session chain that way through `open_persistence_reader`. |
||
|
|
80d6bba3dc |
feat(cron): publish cron.plugin_api for scheduling a named job and reading delivery platforms
A plugin can now create one named follow-up job in a profile, once, with `ensure_named_job`, and ask which platforms cron will deliver a job's output to with `delivery_platforms`, without importing cron.jobs, cron.scheduler, cron.scheduler_provider or private helpers of cron.scheduler_delivery. Both functions forward to the code cron already runs (job creation with scheduler registration, the provider's register_job, and cron's own delivery-target resolver) and add no rule of their own. `home` runs the call with that profile bound whole, the way core binds a profile (its Hermes home, secrets and terminal policy) plus its cron store. A profile other than the process's own also runs under multiplex semantics, as a cron fire for it does, so its own time zone sets a schedule and its home channels and provider credentials are the ones read. `~` is expanded, and the caller's state is restored afterwards, also when the call raises. A `home` that is not an existing directory is never created: `ensure_named_job` raises FileNotFoundError and `delivery_platforms` returns None. A hosted activity cannot act for a profile, so binding `home` is refused there. `AmbiguousJobReference` is re-exported for the duplicate-name case. `ensure_named_job` refuses, with ValueError and before any lookup, a name that is not a non-empty string free of leading and trailing whitespace: cron could never find such a name again, so every call would add a job. The module is listed as a whole in plugin_api.json, documented in the plugin guide, and covered by tests against a real cron store. |
||
|
|
f261cd2d41 |
feat(plugins): plugins can read how the session was created, delegated children and forks
A notification plugin uses these to alert only for the user's own turn, without importing gateway, agent or tools internals. `hermes_cli.plugin_session.session_source()` (and `ctx.session_source()`) returns the label the calling session was created with, its launch policy's `source`: cli, tui, gui, acp, tool or oneshot for a chat a person started; any other non-empty value is the label of a session Hermes started itself. "" says only that no launch policy is bound: outside a session, for a person's messaging chat turn and for a cron run. It reads only the running turn's policy, never `os.environ`. `in_delegated_child(*, include_subprocesses=False)` (and the ctx method) is True while the code runs for a `delegate_task` child; with `include_subprocesses=True` also in a process such a child started. `fork_origin()` (and the ctx method) is "" for a session's own agent and every other regular agent, and the fork's label inside a detached fork: "background_review", "side_question" or "plugin_fork:<plugin id>". The ctx forms answer under `plugins.isolation: host` the same way `ctx.turn_client()` does: the call runs in the gateway, in the calling hook's context. Listed in plugin_api.json (public-api.md regenerated) and the plugin guide. |
||
|
|
c8bb9645e6 |
feat(plugin api): publish the gateway's silence helpers for platform plugins
A platform plugin that decides whether a finished turn's reply is worth sending can now read Hermes's own rule instead of importing private core names: - gateway.response_filters:is_intentional_silence_response: True only when the whole reply is a silence marker such as [SILENT] or NO_REPLY. - gateway.response_filters:strip_trailing_silence_marker: the reply without a marker that closes it on its own line; anything else is unchanged. - gateway.response_filters:is_autonomous_silence_response: the looser rule for runs with no user waiting (cron, webhook), which also treats a reply opening with the bracketed sentinel as silent. The three names are listed in the "Public helpers for platform plugins" group of plugin_api.json, documented as one row of that page's table, and public-api.md is regenerated. No line of gateway/response_filters.py changes, and no other name of that module becomes public. The boundary lint baseline is unchanged: no bundled plugin imports these names, and a full --update would only drop unrelated stale rows. Test: a plugin importing the three names validates with no private-import warning, while silence_allowed from the same module still warns, and the helpers answer what the docs row says. Red on main. |
||
|
|
86ba6e6244 |
docs(release): name the admission check each stable CLI refusal skips
stable-releases.md said both refused stable CLIs would skip the published-release check. Only release_artifacts promote does; channel_releases stable checked the release was published but skipped the candidate digest check against the final release receipt. The paragraph now names each one. |
||
|
|
537e99ed6e |
fix(release): refuse the stable role in the channel_releases CLI
`python -m scripts.releases.channel_releases stable` called
publish_release("stable-release") directly. That skipped advance_stable's
check of the candidate digest against the final release receipt and ran
outside the stable-release concurrency group. It reached the same stable
feeds, and with this PR the DMG alias and downloads page, that
|
||
|
|
b1469d1641 |
fix(release): let an older pending advance pass a stable page already ahead
The stable downloads page has a second writer on main: render-builds-table
in stable-release.yml's `complete` step renders a full-desktop release's
page before the ordered publication pass runs. If an older published
release's advance was still pending, that step put the page ahead of it.
The sequencer advances oldest first, so StableDownloads.prepare for the
older release then refused with "Refusing to move the stable downloads
page backward", on every rerun. Since the standalone CLI no longer
promotes stable, nothing could clear it.
Feed order is checked before promotion, so a page describing a newer
release can only be that renderer's. _check_stable_page_state now leaves
it as it is with a warning, as the renderer's own write_channel_page does,
and returns the bytes that should be live plus the write conditions (None:
no write). The older advance moves the feeds and the DMG alias, and the
public read-back checks the page that is actually live. The page is still
never moved backward.
In test_stable_promotion_rejects_stale_order_for_dmg_and_page, the
page-only-ahead case raised on
|
||
|
|
e68a1d67e2 |
fix(desktop): sign, notarize, staple, and verify outer macOS DMG
Sign, notarize, staple, and Gatekeeper-verify the outer macOS .dmg container in an electron-builder artifactBuildCompleted hook while keeping inner .app notarization (afterSign) intact for Squirrel.Mac .zip updates. - Reuse notarize.mjs auth resolution and 4h LOST_CONTACT / CloudKit retry logic in apps/desktop/scripts/notarize-dmg.mjs, signing the outer .dmg with Developer ID Application + --timestamp (which dmg-builder's built-in dmg.sign omits) using the packager's active codeSigningInfo keychain. - Verify codesign, stapler validate (with LOST_CONTACT retries), and spctl -a -vv -t open --context context:primary-signature, then rebuild .dmg.blockmap and update event.updateInfo before artifactCreated fires so PublishManager writes post-staple sha512/size to *-mac.yml. - Enforce outer DMG codesign, team match, .dmg.blockmap size, and *-mac.yml consistency in scripts/bundles/release_artifacts.py, and verify outer DMG signature, stapler ticket, Gatekeeper policy, and team match before mounting in tests/install/macos-bundle-smoke.sh. |
||
|
|
c1494b2ff2 |
docs(release): say a publication rerun never backfills stable downloads
stable-releases.md told readers to repair a partial stable publication by running Stable Release Publication again, which reads as if a rerun also fills in a missing DMG alias or downloads page. It does not: the sequencer skips a release at or below the stable head unless _unfinished_desktop_head finds its candidate pointer or Docker aliases behind, so a release that finished its advance is never promoted again. The paragraph now says so, and that the unversioned DMG and the page change only with a full-desktop promotion. |
||
|
|
ff616309d5 |
fix(release): refuse stable candidates in the standalone promote CLI
python -m scripts.bundles.release_artifacts promote checked the pinned candidate digest but neither required the published release nor ran inside the stable-release concurrency group. A manual replay could therefore pass the stable DMG alias's order check and then overwrite a newer alias that a concurrent controller promotion had just copied. R2's CopyObject takes no destination If-Match, so the copy itself cannot be a compare-and-swap. Promoting a staged draft needed no race at all. The CLI now refuses a stable candidate, payload tag or attempt ref, before it reads anything. Stable promotion runs only through the Stable Release Publication sequencer (channel_releases.advance_stable -> publish_release -> promote_stable_feeds), which already requires the published release and serializes every stable writer. Canary candidates still promote through the CLI. The renderer harness test now promotes through promote_stable_feeds, as the sequencer does, instead of the CLI. stable-releases.md says only the controller promotes stable, and that a partial publication is repaired by running Stable Release Publication again. |
||
|
|
06296e269e |
feat(plugins): tell plugins which prompt a gateway session is waiting on
Add two observer hooks, on_session_prompt and on_session_prompt_settled, fired by the gateway session owner for each prompt a person answers for a session's viewers, with the id that answers it: - approval / clarify: when SessionAuthority.register_approval / register_clarify has published the approval.request / clarify.request event (prompt_id = the event's prompt_id); settled whenever the prompt leaves PendingControls.pending (snapshot, a remote_responders answer, a managed worker's prompt_settled frame), reason "settled". - request frames: when session_server_requests._ask has opened and written a sudo, secret, clarify (batch), vault.unlock_prompt, vault.code or vault.save_login frame (prompt_id = the srq- id); settled after its request.cancel with that event's reason. Window requests, replay=False requests and an _ask that returns early never fire. params is a deep copy of what the viewers received with every string force-redacted through redact_approval_display(force=True); it never holds an answer. Calls are queued to one FIFO worker thread, so plugin code never runs under event_stream.lock or the request registry lock, on the agent thread or on the event loop, and each runs in the owning profile's owner_scope (for a request frame: the served authority whose live session owns the stream, else the asker's context). Plugin exceptions are logged at debug and swallowed. Event payloads, publish order, open_requests replay, return values and on_human_input_* are unchanged. Both names join VALID_HOOKS and are documented in the observer-hooks, hooks, plugins and plugin developer guide pages. |
||
|
|
4d4de7efb9 | feat(release): publish stable macOS DMG alias and downloads page on promotion | ||
|
|
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>
|
||
|
|
a15b971039 |
docs(shared-metrics): narrow the no-sidecar promise for group chat reads
Some checks failed
A store no process has open is read immutable and gains no -wal/-shm files. A store copied with its -wal but not its -shm is read normally so its WAL rows count, and SQLite adds the -shm it needs. The docs said no read ever adds them. The new test fails if that case is read immutable (its group chats would be missed). Raised in review by Mark S. |
||
|
|
5bfa6f442c |
feat(shared-metrics): say who hosts the install in the daily snapshot
Opt-in shared metrics could not tell an install a hosting platform runs from a self-hosted one (both may run the same container image), so nothing could be split by it. - hermes.install.snapshot gains hosting: nous_cloud when the hosting platform sets HERMES_HOSTING=nous_cloud in the container env, else self_hosted. The raw value is never recorded and no account, agent or machine identifier is added. - An env var rather than a config key: it describes the machine, and config.yaml travels with a profile when it moves hosts. The new name carries a reviewed HX002 allow comment. - hosting ships with the group chat counts, so the legacy field sets treat them as one generation: earlier shapes lack both, and a snapshot whose group chat counts could not be read keeps hosting. - v4 schema extended in place with the optional field; docs bullet added. |
||
|
|
29cfe1d201 |
feat(shared-metrics): count group chats in the daily install snapshot
Opt-in shared metrics could not say how many group chats an install has, how many are in use, or how many involve bots on another computer. - hermes.install.snapshot gains four size buckets: group chats that exist (not disbanded), ones with a message posted in the last 7 days, ones created in the last 7 days, and ones with a member served by another gateway (a negotiated room link). - A gateway keeps the group chats it hosts in its profile's state.db, so each profile's snapshot counts those. The root profile's also counts a standalone backend's in the root shared-state.db that its gateway has not taken over: rooms already handed over are fenced and skipped, and a room an upgraded install holds in both stores counts once. - The stores are only read: a missing one reads 0 and is never created, one no process has open is read immutable so it gains no -wal/-shm files, and the path is URI-encoded. A store that cannot be read leaves the fields out rather than reporting a false 0, and never costs the rest of the snapshot. Only bucketed counts leave the machine. - Pre-upgrade and unreadable-store snapshot shapes stay valid (legacy field sets), and the v4 schema is extended in place with optional fields. - install_snapshot_fields moves from the contract (at the 2,000-line cap) to the snapshot module, its only caller. |
||
|
|
f95d93a445 |
docs(plugins): the reserved provider folder name still re-installs from its recorded source
The provider plugin guide and the reserved-name test module said install always refuses a plugin named model-providers. An existing install of that name re-installs from its recorded source, as the update test shows; both now say so. |
||
|
|
f1b687b8ce |
fix(plugins): install refuses the reserved provider-plugins folder name
Provider discovery loads every package inside plugins/model-providers/ without a plugins.enabled entry; that is how hand-placed provider plugins work. A plugin whose manifest named itself model-providers was installed as that folder, so its packages loaded as providers while install, `hermes plugins list` and `hermes plugins disable` all said it was not on. The install core now refuses that name (any letter case) right after the existing name check and before any file, lock or config is touched, with the same error type and exit code as other invalid names. Every install surface (CLI with or without --force/--enable, dashboard, TUI, packs) goes through it. Hand-placed providers in that folder load as before, and re-cloning an existing install of that name from its recorded source (the update path for subdirectory installs) is unchanged. Reported-by: @egilewski |
||
|
|
28c5a1bfae |
docs(gateway): make the presence and hello comments say what the code does
- Presence records are dropped by a report that leaves their session out, by away, by a detach (reports) and by the per-source bound; no timer ages one. - Observing input cannot fail a request because both callers log and carry on. - can_alert is None only while no report of the connection counts for the session; a report that leaves it out says true. - resolve() notes any result frame to a replayable request, a skip or cancel included, not only "a person's answer". - A hello with an unknown key answers 4000 from the generic unknown-key check; other problems answer 4001. |
||
|
|
fd9e40bef1 |
fix(gateway): advertise client_activity only where reports are kept
client.capabilities answered client_activity: true on every transport, but true means "this connection keeps client.activity reports", and a transport without presence (stdio) accepts a report and keeps nothing. It now answers true only when the calling transport keeps presence; the contract field and the developer guide say so. |
||
|
|
09136943b6 |
fix(gateway): bound the session-id length presence keeps
Presence capped each connection at 16 records per source, but a session id could be any length: one accepted client.activity report naming 16 ids of 1 MiB each stayed in memory for the life of the socket, and touch() kept whatever session_id an input request carried, even one the request was then refused for. client.activity now refuses an id over 256 characters (4001, nothing changes) and touch() ignores one. The limit is one named constant, MAX_SESSION_ID_CHARS; the contract's sessions items and the developer guide state it. |
||
|
|
3829eed29e |
feat(plugins): plugins can read the turn's client and who is attached to its session
A notification plugin uses these to skip a phone alert while the user is active at the client that sent the turn. `hermes_cli.plugin_session.turn_client()` (and `ctx.turn_client()`) returns the label the submitting connection announced, from the turn's own admission stamp, or None outside a turn, in a delegated child, and for unannounced, messaging and cron turns. `session_viewers()` (and `ctx.session_viewers()`) lists the connections attached to the calling session with their idle data (`gateway.session_presence.viewers`). The session comes only from what the calling task-local context bound (never `os.environ`): a turn's, or the one a plugin's own slash command was typed in, which the gateway binds the same way (no turn runs there, so `turn_client()` is None). A context with only a route bound names no session and reads []. The live session must answer to the bound route, so another session's id is never borrowed. A delegated child, which runs in a copy of its parent's context, reads []. The authority is the one `TurnRunner` binds its owner with: the active runtime scope's, so a routed profile's turn reads its own authority, never the launch profile's. No gateway in the process (CLI, managed worker, plugin host): []. Both are labels and reports clients chose: attribution only. Listed in plugin_api.json (public-api.md regenerated) and the plugin guide. |
||
|
|
dcc20cede9 |
feat(gateway): advertise client identity and activity; Desktop and Webapp say hello
`runtime.describe` lists `client-identity-v1` and `client-activity-v1`,
so a client can tell an owner that keeps a connection's label and
activity reports from an older one.
The shared JSON-RPC channel takes an optional `clientIdentity` from its
host and, once per connection generation, right after its
`server_requests` call, sends `client.capabilities {client}` as a call
of its own, ignoring an error reply (an older backend refuses the
unknown param for that call only). A host that names none sends
nothing, so the TUI and other users of the channel stay unannounced.
The Desktop names itself `hermes-desktop` / `desktop` in Electron and
`hermes-webapp` / `webapp` behind the browser bridge. The version is
this machine's own build (the install's version, then the release it
was built from, then the display string), left out when it is a
placeholder or not a valid label version. Reading it asks the backend
and the local install, which takes seconds on a cold start, so the
hello waits at most one second for it and goes without; the read is
kept, and later connections of the window carry it.
The developer guide describes the hello, the kinds (sent on
`session.create` only to an owner with `client-identity-v1`) and
`client.activity`. All of it is attribution only and grants nothing.
|
||
|
|
33a8ba6346 |
feat(gateway): track which attached clients were recently used
A notification plugin needs to know, at the end of a turn, whether the user is at a client that shows the session, so a phone can stay quiet. gateway/session_presence.py keeps that per connection and session, in memory only: one "last input" time fed by input the owner sees on the connection (prompt submit, queued steer/replace, approval and clarify answers, interrupt, steer, redirect; touched once from dispatch, and a person's accepted answer to a server request card) and by the client's new `client.activity` reports (`now - idle_seconds`, with the basis of the evidence and whether the client can alert the user). The newest evidence wins. A report is the connection's whole statement: records of sessions it does not list are dropped, owner-seen input included. `away` clears the connection's records. A connection keeps at most 16 records of each source (reports, owner-seen input), so a report naming 16 sessions and input on them never push each other out. One socket can serve several profiles and session ids are unique only per profile: owner-seen input is kept for the profile that saw it, and a report (ids only) counts at read time for the one profile the connection is attached to that id in, for none when the id is ambiguous. `viewers(authority, session_id)` lists the connections attached to a live session right now, with the hello's name and kind. A detached or closed connection is not a viewer. `client.capabilities` answers `client_activity: true` so a client reports only to a backend that keeps the reports. Nothing here reaches a prompt, a permission or a toolset. The serve handler ledger and its generated page list `client.activity`. |
||
|
|
e7ce85259b |
feat(desktop): a plugin can run a profile's backend on this computer (#156727)
* feat(desktop): a plugin can run a profile's backend on this computer
A desktop plugin that runs a profile's whole backend itself (the
OpenShell sandbox plugin is the first) needs the desktop to follow it:
route that profile to the plugin's backend and back, never start it
locally while core marks it as run elsewhere, and show the switch and
restarts as one state instead of a dropped connection.
Plugin SDK:
- host.setProfileBackend({ plugin, profile, purpose?, prepare? | url,
token }) and host.clearProfileBackend({ plugin, profile,
beforeApply? }), plus host.profileBackendFeatures. Main confirms each
change natively (naming the plugin and the profile), accepts a
loopback address only, and refuses a profile another plugin runs or
the user connected to a remote host. prepare / beforeApply run between
the user's answer and the switch on a one-time grant.
- The route is the per-profile `mode: 'remote'` entry with
`launcher: { plugin }`. It survives the connection.json read, is
never matched to a registered gateway or migrated into one, and a
plugin-run primary leaves every other local profile on this host's
backend. A switch writes (and on failure restores) connection.json
only: the machine's saved-gateways list is left alone.
Desktop behaviour:
- connection:applied names the one profile that moved; the window
redials only that profile in place (primary, pooled, or riding the
shared host socket), with no switch barrier, list wipe or profile hop.
A profile handed back to the shared host socket stays the profile the
window shows and its requests name.
- The host answers a plugin-run profile's profile list, lists "This
device" from a host backend when the plugin runs the primary, and
keeps the rail on one local source.
- Fail closed on core's profiles_run_elsewhere marker: gateway ensure,
pooled dials and the shared host backend refuse a marked profile.
- Nothing in a plugin-run or marked home is copied into the renderer's
plugin root.
- "Starting sandbox…", "Restarting sandbox…", "Stopping sandbox…": from
the SDK switch, or while the connection is down from the plugin's
GET /api/plugins/<plugin>/status. Requests cut off by a planned
restart wait for the backend; a heartbeat-ack timeout counts as a
transport loss.
- The composer keeps a message away from a backend about to go away.
While the profile moves to another backend ("Starting sandbox…",
"Stopping sandbox…") a message can be neither sent nor queued: Send
is off and the message stays in the composer, and nothing is sent by
itself afterwards. While the same backend restarts, a message waits
in the chat's local queue, also with the connection down, and is
sent once when the backend is back. Slash commands still run; other
profiles' chats are not affected.
- So that a message held for a restart arrives exactly once: a new
chat's queue drains as the chat's first message, the sent entry is
removed from the queue it moved to when the chat got its stored id,
a new chat's queue is never a dead-session prune candidate, and a
queued send that a restarted backend refuses as "session not found"
before admission is offered again on the resumed session.
- The rail badges the profile Sandboxed and hides the remote-host
dialog for it.
Refactors to stay inside the code-health ratchet, no behaviour change:
sanitizeConnectionProfiles moves to connection-profiles.ts, gateway.ts's
state container to gateway-registry-state.ts, resolveDesktopRemoteRoute's
per-profile branch to profileOverrideRoute, the rail's corner badge to
RunsElsewhereBadge.
Docs: desktop-plugin-sdk.md documents the calls, the confirm, the
marker, the status route and what the composer does during each
transition.
* fix(desktop): plugin profile-backend switch, review follow-up
Fixes from the review of the plugin-run profile backend, one paragraph
per finding, and one fix for a hang found in two-window testing of the
switch (the paragraph on dials in flight).
Main process:
- Clearing keeps the profile's local entry. A profile's own
`{ mode: 'local', savedSsh }` entry rides on the launcher entry
(`savedSsh` survives the connection.json read beside `launcher`) and
the clear writes it back, so the profile keeps its saved SSH settings
and stays on this computer under a remote primary. A profile that had
no entry has none after the clear.
- A failed switch puts back its own entry only. A switch replaces one
profile's entry in connection.json as the file is at that moment; when
the teardown fails it restores that entry alone, and only while it is
still the one it wrote. Another profile's switch, or a newer route for
the same profile, that landed meanwhile stays.
- After a confirm that `set` or `clear` showed itself, who routes the
profile is checked again immediately before the write. The grant
paths already checked in the same tick as the write.
- The profile-scoped connection:applied goes to every open window; each
redials the profile on its own socket. The bare event of a Settings
apply is main's again: main window only, no payload.
- A switch retires the dials still in flight for the route it replaces.
A launcher is gone seconds before its route is cleared, and a window
that lost its socket asks main for the profile's backend in that gap.
Once main had dropped the dead launcher's descriptor, that dial waited
on the launcher's address for the whole readiness limit (three
minutes) and, being in flight, answered every later dial of the
profile: the windows were told the profile moved, dialed again and got
the old wait, so the profile had no backend until it timed out.
Writing a profile's entry now drops its pooled descriptor and forgets
its dial claims in the same tick, also when a failed switch puts the
entry back. BackendDialClaims.forget (new) rejects the callers already
waiting, so a window's reconnect fails that attempt at once and tries
again instead of sitting out its own 20 s limit. A dial nobody
forgets gives up its claim when it settles, as before; its callers
are answered one microtask later.
This fix is covered by unit tests. The hang was seen twice in live
switch-offs on the unfixed build and did not recur in 22 further ones,
17 of them with the fix: its condition did not arise again, so no live
run shows the fix at work.
- With a plugin-run primary, the host lists profiles from the first
local profile that no plugin runs, core does not mark and the user has
not connected to a remote host. With none left the call fails with
that reason.
- The host answers a plugin-run profile's GET /api/profiles and
/api/profiles/active also when the request is pinned to "This
device". A request pinned to a remote, cloud or SSH gateway is still
that gateway's.
- The profiles_run_elsewhere reader treats only a missing folder, or one
it is denied, as "nothing marked". A file in the folder's place marks
every profile, matching core's reader in #156725.
- The test of the scoped-plugin exclusion now creates the app root, so
it fails without the exclusion.
Renderer:
- A request another surface sends through the composer (the review
pane's ship button, a reply's Continue, a preview widget, a plugin's
composer.submit) is not taken while the profile moves to another
backend. The queue panel's send-now and steer-now, and the second
Enter, do nothing during any transition.
- A launcher status answer that comes back after the profile's
transition ended or was replaced changes nothing, and a switch's wait
for its socket ends only the state it was started for.
- A request cut off by a heartbeat-ack timeout is sent again only during
a planned transition that ends as planned. With none the caller gets
the error, as on main.
Corrections to the first commit's message:
- "a heartbeat-ack timeout counts as a transport loss": outside a
planned transition its request is no longer sent again.
- "A switch writes (and on failure restores) connection.json only": it
restores that profile's entry, not the file.
- "the window redials only that profile in place": every open window
does.
Docs: desktop-plugin-sdk.md says what happens to a profile home after
the switch back (its desktop plugins load and Hermes's own backend reads
it again, so a launcher should grant plugins/ and desktop-plugins/
read-only inside its sandbox), that the composer does not take
host.composer.submit during a switch, and that a heartbeat timeout is
sent again only during a planned transition.
* fix(desktop): a profile switch leaves another gateway's windows alone
Second review follow-up to the plugin-run profile backend.
connection:applied { profile } names a profile of this computer, and
since the first follow-up it goes to every open window. A window
matched it by the profile's name alone, so a window connected to
another gateway (one from the saved-gateways list) whose profile has
the same name took the event as its own:
- With that gateway's `work` (or `default`) as the window's own
profile, the in-place redial declines a registry-scoped primary and
the full connection switch ran: the open chat became a fresh draft,
the session list was wiped, the terminals were closed and the
unchanged gateway was dialed again. The same happened to a window
still starting on that gateway.
- Showing that gateway's `work` through the gateway's own socket, the
window asked main for this computer's `work`, dialed it and put it
in front, so the chat was on the local backend.
The window now decides by its own connection. When its primary socket
is a registered gateway other than "This device", that socket and
whatever the window shows through it stay as they are; only a socket
the window dialed for the local profile itself is redialed, as before.
A window on this computer, also one opened on "This device" from the
gateway list, behaves as before. Main still tells every window: it
records only the route a window has in front, and a window on another
gateway can hold a socket of the local profile.
Not changed: a window in the first moments of its start, before main
has answered what it connects to, cannot tell whose profile is meant.
If its remembered profile has the event's name it starts its
connection again through the full switch and ends on its own gateway.
The first follow-up's message says of the profile-scoped event that
each window "redials the profile on its own socket", and the first
commit's that "the window redials only that profile in place". Neither
held for a window on another gateway's profile of the same name.
Docs: desktop-plugin-sdk.md says a window connected to another gateway
is left as it is.
* refactor(desktop): keep the plugin SDK barrel within its line cap
After the merge of main, apps/desktop/src/sdk/index.ts had 2,003 lines and the code-health check
refused it: main grew the file by four lines and this branch adds seven. The check caps the
file at 2,000 lines.
This branch's seven lines become four. profile-backend.ts exports its three `host` entries as
one object and `host` spreads it, and the two input types are re-exported from
plugin-contract.ts, which the barrel already re-exports whole. A plugin sees the same
`host.setProfileBackend`, `host.clearProfileBackend` and `host.profileBackendFeatures` and the
same exported types. A test in host-state.test.ts now checks that `host` carries the three
entries; no test did before.
* fix(desktop): a planned restart or switch sends again only requests that are safe to repeat
While a plugin restarts or switches a profile's backend, the app held every request the
connection cut and sent it again once the backend was back. A request the old backend had
already received could then run twice: a pet generation, a /background task or a steer in
flight when the sandbox restarted was started a second time on the backend that came back, and
during a switch on the backend that replaced it. Both cuts did it, the heartbeat timeout of a
backend that hangs and the closed socket of a switch.
Inside a planned transition a cut request is now sent again only when a second run cannot
repeat work: the socket was down before the request was written, the request is one of two
reads the app repeats anyway (session.resume, session.history), or it carries a submission_id
or an input_id, by which the backend recognises a request it has already taken. Every other
request fails with the connection's error at once and nothing sends it again; a method nobody
classified is in that group. The list of reads has a test that names its members.
Outside a planned transition nothing changes: a closed socket is retried as on main and a
heartbeat timeout is not. A message typed during "Restarting sandbox…" still waits in the queue
and is sent once with its submission_id.
* fix(desktop): a window does not stay on the host backend when a moved profile's route lookup fails
When a plugin takes over a profile, each window redials that profile in place. A window that
showed the profile through the shared host socket first asks the main process for the profile's
new route. Since the merge of main that lookup rejects on an error or its timeout, and the
redial logged the failure once and gave up: the window went on showing the profile and sent its
chat to this computer's backend, which no longer serves it. Nothing asked again.
The redial is now tried again with the reconnect backoff for as long as the window shows the
profile through the primary socket. It stops when the lookup answers, when the window shows
another profile, or when the window closes. A redial that is waiting leaves the profile alone
when a newer move has already put it on a socket of its own.
A profile that had no socket of its own also starts on its new route without failure history
now. A background request for it whose lookup had failed before the move left a failed-dial
record, and the first background requests after the move were refused with "is reconnecting"
until that record's wait ran out.
* fix(desktop): the composer stays held for as long as a plugin's switch hook runs
During a switch the composer and the queue hold messages so that none goes to the backend the
switch is about to retire. That hold ended 180 seconds after the user's answer although the
plugin's `prepare` or `beforeApply` was still running: Send worked again and queued messages
went to the old backend. A first start of a sandbox can take longer than that. A stop begun
right after a slow start also got only what was left of the first 180 seconds.
The switch's state now lasts until the SDK call returns. Its deadline covers a hook of up to
10 minutes and the window's reconnect after it, so it only ends a hook that never returns. A
transition of another kind or from another source that replaces one gets a deadline of its own.
The SDK guide says how long a hook may run, and that the user's answer is kept for 5 minutes:
after a hook that returns later than that, the app asks once more before it switches.
* test(desktop): cover nine launched-profile guards that no test noticed
Nine lines that keep a profile a plugin runs off the wrong backend could each be removed with
every test of this branch still green. Six are calls in main.ts: the refusal of a marked profile
at a pooled dial, on the shared host backend and at the primary start, the route option that
gives other local profiles a backend of their own under a plugin-run primary, the skip of a
sandbox-writable home in the plugin root, and the host's own answer to a plugin-run profile's
listing. Three are in the renderer.
The first new case covers the one with the worst outcome: when the window's primary profile
moves to a plugin, a profile shown through the primary socket resolves its own route again;
without that, its requests would reach the other profile's plugin backend. The others cover the
primary's in-place redial during a connection-wide switch and the hook that ends "Restarting
sandbox…" when the socket opens. main.ts has no unit harness, so its six calls are checked by
reading the source, as oauth-login-flights.test.ts already does.
One more case covers a request that carries an input_id, the half of the re-send rule that the
earlier commit left without a test. No product code changes.
* fix(desktop): a profile whose plugin is not loaded can be given back to this computer
A profile a plugin runs keeps its route when the plugin is removed, switched off or fails to
load. Only that plugin's own page could give the profile back, and the profile rail hides the
remote-host dialog for such a profile, so nothing in the app could move it. With the plugin's
backend gone as well, the profile had no backend at all.
The profile's menu on the rail now has one entry, "Run on this computer…", while the plugin
named in the profile's route is not loaded. It asks the main process to clear the route for
that plugin, and the main process asks the person in its own dialog before it changes anything.
While the plugin is loaded the entry is not shown: the plugin's page stays the way to switch.
The rail builds the entry that changes where a profile runs in one place: this entry for a
profile whose plugin is gone, the remote-host dialog for any other profile, and none for a
profile whose plugin is loaded. The string is added in every locale.
* refactor(desktop): each launched-profile guard runs inside the action it guards
Six places in main.ts keep a profile a plugin runs off this computer's own backend. Their only
tests read main.ts and matched its text with regular expressions. A formatting change could
break those tests while a guard that no longer worked could pass them, and AGENTS.md asks for
behaviour contracts and never for source-reading tests. That test file is removed.
The guards move next to what they guard, in the launched-profile host, so that main.ts calls one
function for each and the function can be tested with its dependencies:
- `startLocally(profile, start, ...)` refuses a profile core marks as run elsewhere before it
calls `start`. The pooled dial and the primary start go through it.
- `serveByScope(profile, route, join)` does the same before a profile joins the shared host
backend.
- `routeOptions(config, options)` adds whether a plugin runs the primary profile, so another
local profile is not routed to that plugin's backend.
- `answerOr(request, pinned, forward)` answers a launched profile's listing from this computer
and passes every other request on. The rest of `handleHermesApiRequest` became
`forwardHermesApiRequest`, unchanged.
- `registerFsIpc` now requires the check that names a sandbox-writable home.
The tests call these functions: a marked profile never reaches the start or the join callback,
a launched profile's listing never reaches `forward`, another local profile gets a backend of
its own under a plugin-run primary, and the plugin-root handler takes nothing from a home the
check names. main.ts itself still cannot be loaded in a test, so that it calls these functions
is not covered.
* fix(desktop): a profile's socket of the explicit local connection follows the plugin's switch
A window reaches this computer's profiles through two doors: the profile itself, and the
gateways list's "This device" (the explicit `local` connection). A socket opened through the
second door has a scope of its own. When a plugin took a profile over, or gave it back, the
window retired and redialed only the profile's legacy socket. A chat on the other socket stayed
connected to the backend the profile had left: after a switch on it kept talking to this
computer's backend, after a switch back to the plugin's. The window where this shows first is
one opened on another computer's gateway that also holds this computer's profile.
The redial of a moved profile now covers both of the profile's scopes. The one the window shows
is redialed in place through its own door, and one in the background is closed so that its next
use reads the new route. In a window opened on This device, a profile the plugin gives back
rides the window's one host socket again and stays the profile the window shows. A same-named
profile of a registered gateway on another computer has a scope of its own and is left alone,
with its sockets. What had failed on the old route is forgotten for both scopes. A window whose
primary profile moves takes the same path for a socket it opened beside the primary one.
This has been so since the first commit of this branch.
* fix(desktop): a job that waited on a profile's backend does not act on a newer choice
Three jobs change what a window shows after they waited on something: the reconnect when a
plugin's launcher reports its backend running again, the redial of a profile whose backend a
plugin moved (with its retry after a failed route lookup), and the second step of a redial of
the window's primary profile. Each read which profile the window showed, waited, and then acted
on what the window showed at that later moment, or on what it had shown before.
A person met it in four ways. A profile restarted, the person opened a chat of another profile,
and when the first profile came back the window closed and redialed the socket of that other
chat, which cut its requests. A plugin took a profile over while the person's pick of another
profile was still connecting, and the redial put the window back on the profile it had just
left. A plugin took the window's primary profile over while a second profile was shown through
its socket, the person went back to the primary profile, and the redial brought the second
profile back. A profile moved twice in a row with a failed route lookup at the first move, and
the first move's redial asked again while the second move's redial was still connecting, closed
that socket and dialed another.
One function in the profile store now answers whether such a job may still act:
foregroundShows(profile). It answers once a pick that is still connecting has landed or failed,
and says whether the window shows the profile then. The three jobs ask it right before each
change. A pick that failed leaves the window on the profile, so the job still acts for it. The
redial of a moved profile also stops waiting to ask again once the same profile has moved
again: the newest move owns the redial.
This has been so since the first commit of this branch. The retry is from the commit that
added it (a window does not stay on the host backend when a moved profile's route lookup fails).
|
||
|
|
98ea47f590 |
fix(release): build tagless when the default branch isn't main
372116c747 answered Greptile's renamed-branch finding by refusing --build-commit outright when the repository's default branch isn't the Stable Release controller branch, so a fork defaulting to develop lost the commit build that main gave it. On such a repository --build-commit now dispatches the tagless desktop-bundled-release.yml build on the default branch, exactly what main did (commit_build.admit accepts the default branch there). No claim is created, because Stable Release would refuse its run. --only/--with/--without need Stable Release, so they are still refused there before anything is dispatched. The page is the tagless releases/commit/<sha>/index.html. Reported by @kshitijk4poor on #158714. |
||
|
|
46ff6a3bc6 |
fix(release): read a declared claim-build contract, not the claim readers' text
commit_supports_claim_tag chose the claim path when a commit's tree had the three claim-tag readers (is_commit_tag, COMMIT_TAG_RE, the canary|commit pattern). The PR's own first commit, bd507fa031, has all three but none of the packaging: its desktop_inputs still pops HERMES_BUILD_COMMIT for every tag and desktop_prepare reads only canary_timestamp, so a claim on it failed its native builds with "stable preparation requires its exact claim tag" instead of taking the tagless path. Any git show failure also returned "legacy", so a failed read looked like an old commit. A claimed tree now declares the contract its packaging honours in scripts/releases/commit_claim_build.txt, read with git (never by running the tree). No file means the tagless path; a contract outside stable.CLAIM_BUILD_VERSIONS, or any failed read, raises and stops the run in stable verify. Every commit of this PR before this one now builds as legacy, which works for all of them. Reported by @kshitijk4poor on #158714. |
||
|
|
0c55aa6016 |
feat(release): wire commit claims into stable-release.yml with read-only native legs
Routes commit. and channel. claims to cache-mode: read native legs (Windows, macOS, and a split termux-deb-commit leg with no APT GPG signing key access), closes main's win32-assembly-v1 prefix restore-keys gap, keeps pre-claim commits buildable via trusted controller checkouts and legacyCommitBuild metadata, and renders every staged commit-claim asset (.msixbundle, .msix, .dmg, .zip, .deb) on the claim page. Co-authored-by: BearHuddleston <bear@bearhuddleston.dev> |
||
|
|
da8e7d71ab |
test(profiles): pin the review-surfaced branches of the profile lifecycle fixes
Optional nits from BearHuddleston's approving reviews of #158223, #158271, #158272, #158273 and #158211 (tracker #155595, issuecomment-7059727896), each one of his tested patches unless noted: Tests, each catching a mutant that passed the whole suite before: - F06: a Windows WinError 5 with nothing at the destination stays raw (the os.path.exists() half of publish_staging's fallback). - F16 Edge A: the popped-adapter clause of the unserve finally guard. - F07: import and rename onto an unfinished delete name it (ported to the `incomplete` record main now writes); record_delete_finished's silent FileNotFoundError; an unreadable record reads as incomplete. - F10: the throwaway plugin host is stopped and its registrations disposed; the channel-lost test closes the channel the read-error way, so the child no longer exits on its own inside the asserted window. Docs and dead code: - F16 Edge A: _hold_secondary_claims docstring. - F10: unused contextlib/Callable/Iterator imports; the developer guide says the hooks run in a plugin host of their own. - F09-1: share_auth comment and mirror_launch_credentials docstring follow the _logins_home rule. Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com> |
||
|
|
8f239226bc |
fix(plugins): plugin writes refuse a deleted or renamed profile home
A session still bound to profile b survives `hermes profile delete b` and `hermes profile rename b c`. Its next plugin write recreated profiles/b through a raw mkdir, and nothing raised. Seven plugin state writers now create their directories through mkdir_under_hermes_home, which refuses a missing or tombstoned named home with its existing FileNotFoundError: plugin_data_dir (and the hermes-achievements fallback that duplicates it), the CLI plugins dir, the update-check markers, disk-cleanup state, the Discord recovery ledger, the Weixin account dir and the A2A audit log. Callers that already catch keep skipping the write (Discord recovery, the update-check writers, the disk-cleanup session-end hook and audit log, the A2A audit). The disk-cleanup slash commands reply that the profile no longer exists instead of raising. plugin_data_dir documents the refusal. |
||
|
|
b8478bc161 |
fix(gateway): release a stopped sender's lock whatever its confirmation does
Gate round on 0dd6af2395: run() leaves the release to the confirmation in flight, but a non-OSError from it escaped before the stopped check, and a confirmation the loop cancelled at shutdown released only a lock it had just taken, not the one this sender already held. Both left a lock behind for a gateway that is still running. Once the watcher has stopped, any error is handled like an unusable directory (release what this sender held), and the shutdown callback releases a held lock whatever the thread's answer. The confirmation task's exception is also read when every caller was cancelled (consume_detached_task_result), so asyncio no longer logs its text. Comments and docs the gate found overbroad are narrowed. |
||
|
|
035878e204 |
fix(gateway): a wait asked for in a goodbye's reply holds the next beat
Greptile review of #157287: the goodbye's reply was only logged, so a 429/503 Retry-After or a 401/403 on it was lost and the next beat went out at the end of the quiet minute anyway. The goodbye is still never retried. A wait its reply asks for now moves the end of the quiet minute, the same rule a beat's reply already follows, so a beat that was in flight and settles after it keeps the wait too. The throttle and backoff rule is shared with _settle. |
||
|
|
56cd784e33 |
fix(gateway): settle an owed lock release when the last confirmation is refused
Gate round on 15415f7d87: a lock taken after a cancel was kept while another confirmation was out, and nobody gave it back if that one came back refused or with an OSError. The release is now owed and settled when the last confirmation is done, kept only if the reporter is the sender by then. The closed-loop fallback decides under a lock, since both reporter threads can get there. Also narrows comments and docs the gate found overbroad: which builders drop and restore the stamps, and that a gateway started from the terminal tool still loads a sleep URL from its own profile .env. |
||
|
|
19dc04c935 |
docs(gateway): correct status report comments and docs for this head
Review of #157287 (W1): which children lose the stamps, the reporter (not the package) is what is lazily imported, the restart env comment claimed stamps survive a strip that removes a dotenv sleep URL, and the interval clamp is 60 to 600 seconds. |