Commit Graph

1496 Commits

Author SHA1 Message Date
Teknium
1cf261a8cd refactor(wecom): WeCom leaves core for the wecom Hermes Labs plugin
Both WeCom platforms (AI Bot `wecom`, self-built-app `wecom_callback`) move to
NousResearch/hermes-labs-plugins `wecom/`. Two LEFT_CORE rows (one per
platform, one shared plugin, installed once) whose platform_in_use predicates
replicate core's enable gates per mode. Stacked on the DingTalk removal
(#159638): the platform lists both PRs edit are resolved once here.

Folded from the earlier branch (one commit per step, in order):

  331094ca15a3 Teknium test(gateway): a named profile's port-binder is served only on a default listener, live reconcile too
  The live reconcile builds a named profile's platforms through the same prepare step as startup, so the
  "not served" refusal holds there as well: a LINE secondary with neither api_server nor webhook on the
  default stays unstarted and names the remedy instead of reading as connected. The two LINE named-profile
  reconcile tests now give the default a webhook listener, so their LINE is served at /p/b/ as in a real
  setup; their assertions are unchanged.

  bedc93176b93 Teknium fix(left-core): off-platforms derive from the LEFT_CORE rows; left-core routes name the install
  Same hunk as the QQ Bot (#159640) and Feishu (#159651) PRs, so merge order cannot leave a stale entry.

  - A row whose tools lived in its own hermes-<platform> bundle only (Yuanbao) sets own_platform_only;
    _derive_off_platforms fills off_platforms with every platform core knows plus every platform a
    LEFT_CORE row moved out. The hand list _YUANBAO_OFF_PLATFORMS (which this PR had extended with
    wecom/wecom_callback) is gone. The WeCom rows carry no toolsets (hermes-wecom and
    hermes-wecom-callback bundled core tools only), so they need no off-platforms.
  - Webhook routes: is_known_platform accepts any platform a LEFT_CORE row moved out, so a saved wecom or
    wecom_callback route stays loaded before a secondary profile's plugin registers; without the plugin
    the send fails naming the install.
  - Cron: a deliver route naming a left-core platform whose plugin is not loaded reports the install
    command (delivery error and preflight). tests/cron/test_cron_left_core_platform_route.py runs for
    wecom and wecom_callback.

  05d04a49ccc3 Teknium refactor(wecom): drop the one-install-per-home copy; the installer-race PR carries it generically

  296e4a152f99 Teknium fix(gateway): a secondary port-binder with no default listener is not served, not "connected"
  Under multiplex a secondary profile's port-binding adapter (WeCom callback, LINE, SMS, Teams, ...)
  binds nothing: its app is published for /p/<profile>/ on the default profile's api_server or
  webhook listener. With neither running on the default, connect() still returned True and the
  runner logged "✓ wecom_callback connected (profile: b)" while nothing listened anywhere.

  - Runner: such an adapter is not started; it is stamped `<profile>:<platform>` disabled with
    error_code multiplex_no_shared_listener and a WARNING naming the remedy.
  - Migration preflight: a secondary whose own gateway serves a port-binder today is refused when
    the default enables neither listener (it would be served nowhere after the fold); a secondary
    with no gateway gets the same text as a notice.
  - bind_listener publishes the port it actually bound (`listener_base`); the dashboard topology
    reads that instead of resolving a plugin platform's listen_port in the profile's plugin
    registry, so a parked or cold profile's callback port is reported and no deferred loader runs.

  26cde0b03cdc Teknium refactor(wecom): WeCom moves to the Hermes Labs wecom plugin, opt-in
  WeCom is now a Hermes Labs plugin (NousResearch/hermes-labs-plugins), not an
  official default one. Only homes that used WeCom get it installed, once; a new
  home installs nothing.

  - Both LEFT_CORE rows (bot and callback) carry the labs notice, like Yuanbao
    and DingTalk, merged with the plugins.disabled 'wecom' sentence.
  - Docs pages say "moved to the wecom Hermes Labs plugin" with the labs
    warning (en + zh-Hans); no default-install wording is left.
  - The one-automatic-install-per-plugin seam between default_plugins and the
    left-core migration stays: it is general (any plugin that is both a catalog
    default and a LEFT_CORE row) and now has its tests in test_default_plugins
    with a stand-in plugin instead of the wecom-named ones.

  9c82896ffee9 Teknium fix(wecom): migration preflight and dashboard read plugin capabilities in the owning profile
  - platform_serves_profile_prefix(value, home) reads the adapter class in the
    owning profile's plugin scope, like platform_binds_port: a port-binding
    plugin only a secondary installed is a URL-change notice, not a blocker.
  - A parked profile's plugins are never discovered for either check, nor for the
    dashboard's port readout (read-only probe).

  deb0661c69ea Teknium fix(wecom): review findings on the core removal
  - One automatic install per plugin across both installers: left-core
    `_pending` skips a plugin `_default_plugins_installed` records, and
    default_plugins skips one `_left_core_installed` records, so a removed
    WeCom stays removed whichever ran first.
  - `listen_port` is read in the owning profile's plugin scope: a multiplexed
    secondary (shared-listener routing), migration preflight (per profile home)
    and the dashboard topology (discovers that home's plugins; preflight never
    does, a parked profile's plugins must not run here).
  - `hermes-wecom-callback` keeps resolving: a `hermes-<a-b>` bundle falls back
    to platform `a_b`, and toolset validation accepts it.
  - StandaloneSendPolicy.media_via_adapter moves after reply_file_over so
    positional callers keep their meaning.
  - cron home-target priority keeps wecom (the plugin platform keeps it).
  - `_BUNDLED_ENV_SIBLINGS` removed with its readers' prefix branch.

  c3ec8edb3cc4 Teknium refactor(wecom): WeCom leaves core for the official wecom plugin
  Both WeCom platforms (AI Bot `wecom`, self-built-app `wecom_callback`) move to
  NousResearch/hermes-official-plugins `wecom/`, installed by default on every
  home (catalog `default: true`). Existing users get it automatically: two
  LEFT_CORE rows (one per platform, one shared plugin, installed once) whose
  platform_in_use predicates replicate core's enable gates per mode.

  Generic seams added for the plugin, never a name check left in core:
  - PlatformEntry.listen_port: a plugin platform that binds a host port
    (platform_binds_port, multiplex shared listener, migration blockers,
    dashboard topology). Replaces the wecom_callback rows.
  - StandaloneSendPolicy.media_via_adapter: send_message media through the live
    adapter route. Replaces the _CHUNKED_ROUTES["wecom"] row.
  - cron: a registered plugin platform without a cron env var (home channel from
    config.yaml only) is a valid delivery target. Replaces the wecom_callback row.

  Child-env strip set unchanged: _ADAPTER_SECRET_ENV also carries the
  left-core platform rows' secret_env.
2026-11-28 07:35:40 -08:00
Teknium
69330b0988 refactor: move DingTalk out of core into the dingtalk Hermes Labs plugin
DingTalk (Stream Mode adapter, AI Cards, the QR device-flow login in
hermes_cli/dingtalk_auth.py) now ships as the `dingtalk` plugin in
NousResearch/hermes-labs-plugins: built by Nous Research, not supported.
Same platform name, DINGTALK_* env vars and platforms.dingtalk keys.

Removed: plugins/platforms/dingtalk/**, hermes_cli/dingtalk_auth.py and
its tests, Platform.DINGTALK, the hermes_cli/platforms.py row, the
hermes-dingtalk toolset and its hermes-gateway include, the dingtalk PM
extra (+ uv.lock, nix groups), the platform.dingtalk.emotion locale
strings, builtin-list entries (update allowlist, allowlist env platforms,
webhook/cron deliver sets, dump, dashboard env rows) and the shim rows
for a folder that no longer exists. Comments that named DingTalk as a
core adapter now describe the capability flag instead; no core code
branched on the name. Docs: messaging/dingtalk.md (+ zh-Hans) is a
"moved to the Labs plugin" page.

Kept: DINGTALK_CLIENT_ID/SECRET on the hermes-owned env list (a plugin
manifest cannot claim them), tip t159 (tips are numbered contiguously),
the desktop/TUI session-source names (the plugin keeps the platform name).
hermes-dingtalk stays valid as a retired telemetry toolset name.
2026-11-28 07:11:48 -08:00
Teknium
8542222e56 feat(memory)!: remove the ByteRover and RetainDB memory providers
Nobody took over NousResearch/hermes-plugin-byterover or hermes-plugin-retaindb by the
Oct 15 2026 deadline (D12), so both bundled providers are deleted instead of moved to the
catalog.

- Delete plugins/memory/byterover/, plugins/memory/retaindb/ and the tests that only
  exercised them (provider, multiplex contract, thread-profile and identity-scope files whose
  every case was one of the two; the retaindb secret-scope pair; the two bundled-precedence
  tests that used byterover as the bundled sample).
- memory_provider_migration: a `_REMOVED` name -> label table. A home whose memory.provider
  names one gets "<Label> was removed from Hermes because no one took over maintaining it.
  External memory is off; run `hermes memory setup` to choose another provider." at agent
  start (CLI, Desktop notice, chat platform first reply), on `hermes update`, in
  `hermes memory status`, `hermes memory setup <name>` and `hermes doctor`. No catalog lookup
  and no install for those names; memory.provider is never rewritten. Both names leave
  _LEFT_CORE (no unattended install consent for a plugin that does not exist).
- Drop RETAINDB_API_KEY / RETAINDB_BASE_URL / BRV_API_KEY from OPTIONAL_ENV_VARS, the
  "Bundled providers" help line, ~/.brv-cli/bin from the memory-setup PATH, the two
  boundary-lint baseline lines, and the docs (EN + zh-Hans).
- Kept: agent/redact.py's retaindb_/brv_ key patterns (a leaked key is still a secret).

The empty `honcho: {}` config root was already removed on main (6933155eaf).
2026-11-28 06:39:41 -08:00
Teknium
3ef8bf4f68 fix(plugins): a platform plugin may declare the tools of the bundled platform it takes over
Some checks failed
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (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
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
`hermes plugins validate` failed any declared tool name core already ships, so a
platform plugin that takes over a bundled platform (Feishu, hermes-official-plugins
#517) could not declare its own tools: on a core that still bundles the platform the
names collide, and with provides_tools: [] the same plugin fails the declared-tools
check once core drops the platform. No single manifest passed both.

The collision check now exempts, for a kind: platform plugin named after a platform
core still bundles, that platform's own hermes-<platform> extras (never the shared
core tools), and only when the plugin does not register them on this core. Every
other built-in name, and any registration that would shadow a built-in, still fails.
Install never ran this check (only validate does), so 0.23.4 installs are unaffected.
2026-11-28 03:40:45 -08:00
Victor Kyriazakos
c905e13d0e fix(memory): keep plugin card display data host-only
Strip plugin-card text and directive metadata before session-end and
pre-compress memory-provider hooks while preserving the bounded core line.
2026-11-27 09:41:31 -05:00
Teknium
170d9637ea feat(gateway): idle chats compact in the background on every route, per channel
`compression.idle_compact_after_seconds` only ran at the start of the next turn, so the
user's first message after a long idle waited for the summary, and the gateway's
background compaction ran only at the prompt-cache edge, i.e. only on routes with cache
keep-alives. Local models, custom OpenAI-compatible endpoints and unpriced routes never
compacted in the background.

- The housekeeping tick's cache-edge scan now also claims a cached chat whose idle policy
  has passed (`idle` action, `gateway/run_watchers_idle.py`) when its cache edge claimed
  nothing. It runs the same job: one per session key, the shared semaphore, the chat's
  profile scope and claim gate, the manual-compression pipeline (lease, fence, automatic
  gates, durable cooldown) with the `idle` trigger. No new worker, table or scheduler.
- Before summarising, the turn-start idle gates run on the stored transcript
  (`idle_compaction_admission`, extracted from `_idle_compaction` so both paths share
  them): above the post-compaction floor, grown since the last compaction, no cooldown.
- Once per idle stretch: the claim latches on the agent's last activity, so a refused or
  failed chat is not retried until it has new activity; a success evicts the agent.
- Skips a chat with a turn running or with input an adapter has not dispatched yet
  (pending message, text batch, in-flight guard) or the runner queued.
- A chat whose agent the idle-TTL sweep evicts first is compacted at release when due
  (`_compact_then_release` no longer requires a prompt-cache warmer).
- Silent on the chat; the outcome goes to the gateway log.
- `platforms.<p>.channel_overrides.<id>.idle_compact_after_seconds` overrides the global
  value for one channel (0 turns it off there), resolved through `_channel_override` like
  model/system_prompt/allow_silence and stamped on the agent every turn, so a cached agent
  follows config edits and the background run reads the chat's own policy.

The buffered-input check follows kylebach's #128358 (`_post_reply_idle_has_pending_input`).

Co-authored-by: kylebach <97074323+kylebach@users.noreply.github.com>
2026-11-26 20:48:20 -08:00
Teknium
e068806a92 fix(prompt-cache): a marked request is kept warm from its first send
A request carrying cache_control markers declares its tier (the clock's
Anthropic-spec rule), so the first long reply of a session is covered too; an
automatic cache still has to prove itself on the clock first. The prompt size
is estimated from the payload instead of the previous reply.

Part of #160322.
2026-11-26 20:37:26 -08:00
Teknium
c38c816b55 docs(prompt-cache): keep-alives while a reply generates
Part of #160322.
2026-11-26 20:37:26 -08:00
Teknium
6a73bd9390 fix(prompt-cache): one snapshot for the tier check, upgrade after a committed edge compaction, no cold prune under a live refresh
Three correctness gaps from the /review pass on 02f1ff41, each reproduced on the real SDK
against a local endpoint and scratch SQLite (now regression tests in test_warmer_races.py):

- The tier check read the clock and the in-flight keep-alive mark separately; a reply that
  folded and cleared the mark between the two reads let a turn upgrade over the entry that
  reply had just renewed. warmer.cache_touch_snapshot reads both under the warmer lock the
  fold and the clearing take.
- A committed cache-edge compaction lands ~250 s after the last keep-alive, so the 300 s age
  test kept the next message on 5m though nothing warm matched the rewritten prompt. A
  compaction claimed this stretch whose commit the clock shows (compacted / session_rotated)
  now upgrades the next message; a skipped one still leaves the clock, and the tier, as is.
- prompt_cache_is_cold ignored a keep-alive awaiting its reply, so the turn-start cold prune
  rewrote a prefix that refresh had renewed. It now answers False while one is in flight.
2026-11-26 18:06:51 -08:00
Teknium
bf24d050e1 fix(prompt-cache): never switch tier over a warm 5m entry at the edge or mid-refresh
Two review findings on the 5m keep-alive change, both a needless full re-write on Nous Portal:

- The cache-edge claim moved an auto chat to 1h before its compaction ran. A compaction the
  owner then skipped (a user turn started first) left the 5m entry warm under 1h markers.
  The claim no longer touches the tier: the next message's existing check sees the clock,
  which names the rewritten prompt after a committed compaction (so it upgrades) and the
  warm entry after a skipped one (so it stays on 5m). upgrade_at_compaction is gone.
- A keep-alive still waiting for its reply had renewed the entry, but the tier check only
  saw the clock's last folded touch. The warmer records when each keep-alive went out
  (last_sent_at) and the check counts it as a touch.
2026-11-26 18:06:51 -08:00
Teknium
09599f09a0 fix(prompt-cache): keep 5m chats warm between messages, compact them at the edge
Under cache_ttl: auto a person's chat starts on the 5m tier. Until now it got no idle
keep-alives before its upgrade to 1h, and the cache edge never compacted a window under
30 minutes, so every pause past 5 minutes re-wrote the whole prompt and the chat lost its
cache with nothing done first.

- Idle keep-alives now run on the 5m window too (up to 3 reads, ~17 minutes of cover), so a
  pause they cover keeps the cheap 5m entry.
- The cache edge compacts on any tier once that budget ends (the 30-minute floor is gone),
  under the same context/growth rules as before.
- An auto chat compacted on 5m moves to 1h right there (upgrade_at_compaction): the compacted
  prompt is written fresh anyway, and the chat just idled past its 5m keep-alives.
- The tier still changes only when the 5m entry is gone. Live Nous Portal probes: a request
  asking 1h over a warm 5m entry re-writes the whole prompt at 2x (5m->5m control reads it),
  and a 1h request of the same prompt only reads the 5m entry without extending it.

Backtest on the owner's real calls (34 human chats, agent.log, measured Portal rates):
keeping 5m warm between messages costs 4.1% less than today (1.9% at a 0.1x read rate);
starting on 1h costs 0.9% less.
2026-11-26 18:06:51 -08:00
Teknium
f4e6034a30 feat(plugins): oauth entries can write localhost into the redirect URI
QuickBooks (Intuit) refuses IP addresses in redirect URIs, so the pinned
`http://127.0.0.1:<port><path>` redirect from the previous commit can never
be registered there. `redirect_host: localhost` writes `localhost` into the
redirect URI (authorize and token requests) while the listener still binds
127.0.0.1 only. Validated at admission (127.0.0.1 or localhost), passed into
the PKCE config, and part of the grant fingerprint only when set, so existing
grants stay valid.

Docs note that QuickBooks accepts a localhost redirect for development
(sandbox) keys only; production keys need a public HTTPS redirect.
2026-11-26 18:05:50 -08:00
Teknium
1478d8e174 feat(plugins): oauth entries can pin the redirect URI and comma-join scopes
Some authorization servers accept only a redirect URI registered verbatim
(Linear, QuickBooks) and some want `scope=read,write` instead of the RFC
space join (Linear). A plugin `oauth:` entry could do neither: the login
always bound an OS-assigned port at /callback and always space-joined the
scopes, so `hermes auth add <plugin>:<id>` could not finish a sign-in at
those providers and plugins kept their own token files instead.

- `oauth:` entries take optional `redirect_port` (1024-65535),
  `redirect_path` and `scope_separator` (space or comma); validated at
  admission like the other fields and passed into the PKCE config.
- OAuthPKCEConfig gets `scope_separator`, used at all three join sites
  (authorize URL, stored grant metadata, refresh request).
- The granted-scope check splits on commas or whitespace, so it reads the
  IdP's answer whichever separator it uses.
- The grant fingerprint skips fields left at their default, so existing
  grants of entries that declare none of the new fields stay valid; a
  change to any of them asks for a fresh sign-in like every other field.

Fixes #152732, fixes #149642.
2026-11-26 18:05:50 -08:00
Jeffrey Quesnelle
e0dcc39fb8 docs(delegation): describe delegate_task as the code runs it (#160195)
* docs(kanban): correct the delegate_task comparison table

The table described delegate_task as a blocking call with no resume, no
human control and no audit trail. Top-level calls return a handle and
deliver the result as a later message; a finished or stopped child can
be continued; a running child can be steered or stopped; each child's
transcript is a stored session under the parent's.

The Kanban column overstated three things: a creating chat is subscribed
to completion and block events by default, a dispatched worker can
change only its own card, and `hermes kanban gc` prunes old events of
done and archived tasks.

* docs(delegation): describe delegate_task as the code runs it

Corrections found by checking each statement on the delegation pages
against the source:

- Nesting is decided from depth. delegate_task has no role parameter;
  a passed role is accepted and ignored. The background parameter is
  deprecated and ignored.
- Top-level calls are backgrounded only where the session can receive
  a later message. One-shot runs, cron jobs, Kanban workers, stateless
  API requests, inline gateway chats and a full pool join in the call.
- The blocked tools are delegate_task, clarify, memory, send_message
  and cronjob_manage. execute_code is not blocked.
- A background process survives its session only with
  persist_on_release=true, and never a gateway or host shutdown.
- A crashed or restarted child resumes when delegation.auto_resume is
  on, and stays continuable for delegation.resumable_ttl_hours.
- The schema retry appends the output contract again. Subagent context
  files use the flat 20,000 character cap.
- Routing: native-SDK providers ignore base_url precedence, a provider
  default model applies before the parent's, max output tokens are not
  carried, and /review follows the delegation section by default.
- Failure line, status values, diagnostic dump name and contents,
  /agents rows, the steer delivery point, live transcript fidelity,
  Slack's notice default and the worktree archive step now match the
  strings and behaviour in the code.

* docs(config): delegation defaults and limits match the code

- max_concurrent_children defaults to 10, not 3.
- delegation.max_iterations defaults to 250, not 50.
- max_spawn_depth has a floor of 1 and no ceiling.
- DELEGATION_MAX_CONCURRENT_CHILDREN is read only when the config key
  is null; the shipped default otherwise wins.
- An omitted delegation.api_key inherits the parent's key or uses the
  named provider's own key. OPENAI_API_KEY is not read.
- A task's context rides the child's first user message, not its
  system prompt.
- role="orchestrator" is gone from the delegation section.

* docs(delegation): state when the concurrency env var is read

DELEGATION_MAX_CONCURRENT_CHILDREN is read whenever no config value is
loaded: under --ignore-user-config or --safe-mode, and with the key set
to null. The previous commit named only the null case. The Delegation
page no longer offers the variable as a way to configure the limit.

* docs(kanban): say which chats are subscribed on create

Only a session with a delivery channel is subscribed to a task it
creates: a gateway chat, or a TUI or Desktop session. A classic CLI
run, a cron job or a scripted create is not, and kanban_create reports
it in the result's subscribed flag.
2026-11-25 20:51:41 -05:00
unsupportedpastels
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.
2026-11-25 18:16:54 -05:00
unsupportedpastels
231617ea5a refactor(gemini): extract neutral model-family, URL, and output-budget timeout helpers 2026-11-25 18:16:54 -05:00
unsupportedpastels
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.
2026-11-25 15:46:50 -05:00
unsupportedpastels
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.
2026-11-25 15:46:50 -05:00
kshitijk4poor
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.
2026-11-26 01:53:09 +05:30
Bear Huddleston
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
2026-11-25 12:55:52 -06:00
kshitijk4poor
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
2026-11-25 17:30:16 +05:30
Bear Huddleston
949afabbe7 Merge pull request #159469 from NousResearch/feat/stable-mac-dmg-url
feat(release): publish stable macOS DMG alias and downloads page on promotion
2026-11-24 18:14:31 -06:00
unsupportedpastels
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.
2026-11-24 13:32:49 -05:00
unsupportedpastels
feceed663e fix(cron): keep plugin lookups within one profile 2026-11-24 11:17:04 -05:00
unsupportedpastels
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.
2026-11-24 11:17:04 -05:00
unsupportedpastels
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.
2026-11-24 11:17:04 -05:00
unsupportedpastels
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.
2026-11-24 11:17:04 -05:00
unsupportedpastels
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.
2026-11-24 11:17:04 -05:00
unsupportedpastels
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.
2026-11-24 11:17:04 -05:00
unsupportedpastels
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.
2026-11-24 11:17:04 -05:00
unsupportedpastels
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`.
2026-11-24 11:17:04 -05:00
unsupportedpastels
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.
2026-11-24 11:17:04 -05:00
unsupportedpastels
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.
2026-11-24 11:17:04 -05:00
unsupportedpastels
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.
2026-11-24 11:17:04 -05:00
BearHuddleston
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.
2026-11-24 09:42:12 +00:00
BearHuddleston
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
ff616309d5 closed off in the release_artifacts CLI. No workflow, test or
doc uses that role; stable-release.yml calls only `channel_releases
canary`.

The CLI now refuses `stable` with the reason (exit 2) and publishes
canary as before. test_channel_releases_cli_publishes_canary_and_refuses_stable
did not raise on f4785e7bee and does now.
2026-11-24 09:41:20 +00:00
BearHuddleston
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 274bc33a78 and now promotes the older
release while leaving the newer page alone. stable-releases.md no longer
says the page changes only with promotion.
2026-11-24 09:33:59 +00:00
BearHuddleston
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.
2026-11-24 09:29:12 +00:00
BearHuddleston
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.
2026-11-24 09:13:59 +00:00
BearHuddleston
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.
2026-11-24 09:03:09 +00:00
unsupportedpastels
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.
2026-11-23 23:16:56 -05:00
BearHuddleston
4d4de7efb9 feat(release): publish stable macOS DMG alias and downloads page on promotion 2026-11-24 03:46:07 +00:00
Jeffrey Quesnelle
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>
2026-11-23 21:37:40 -05:00
calvinnwq
a15b971039 docs(shared-metrics): narrow the no-sidecar promise for group chat reads
Some checks failed
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (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
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.
2026-11-23 19:15:41 -05:00
calvinnwq
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.
2026-11-23 19:15:41 -05:00
calvinnwq
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.
2026-11-23 19:15:41 -05:00
unsupportedpastels
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.
2026-11-23 11:44:18 -05:00
unsupportedpastels
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
2026-11-23 11:44:18 -05:00
unsupportedpastels
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.
2026-11-23 11:34:19 -05:00
unsupportedpastels
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.
2026-11-23 11:34:19 -05:00