Commit Graph

1043 Commits

Author SHA1 Message Date
Teknium
38bfb94b5c fix(image_gen): OpenRouter's Grok image row is x-ai/grok-imagine-image-2.0
OpenRouter's Image API catalog (GET /api/v1/images/models) no longer lists
x-ai/grok-imagine-image-quality; it lists x-ai/grok-imagine-image-2.0. Swap
the curated _IMAGE_API_MODELS row, with every knob taken from the live
catalog entry: the same 14 aspect ratios, 1K/2K, n=1, 3 references, plus a
quality enum (low|medium) the old row never declared.

The direct xAI backend keeps grok-imagine-image-quality: xAI's authed
/v1/image-generation-models still serves it.
2026-11-02 07:57:26 -08:00
Teknium
9ef7055f5b test(image_gen): the OpenRouter catalog-contract test reads our tables, not the live catalog
test_catalog_models_are_offered_only_by_openrouter called list_models() with
the network open, so it compared _IMAGE_API_MODELS against OpenRouter's live
/images/models. OpenRouter renamed x-ai/grok-imagine-image-quality to
x-ai/grok-imagine-image-2.0 and main went red on every PR. Refuse the network
inside the check so it verifies the offline tables' contract (OpenRouter offers
every Image API model, Nous Portal none) deterministically.
2026-11-02 07:46:40 -08:00
Teknium
ce02e4686d fix(photon): photon status routing row gives up after 5 s on an unreachable API
The live opt-in row reused list_users' 30 s timeout, so a black-holed API stalled
`hermes photon status` (previously offline-only) for 30 s. Thread a timeout through
list_users/find_user_by_phone and use 5 s for the status row only.
2026-10-31 22:09:38 -07:00
Teknium
a97f13ff3f fix(photon): setup without a phone number ends on saved-not-live, not "complete"
routing_live defaulted to True, so skipping the phone prompt still printed
"Photon setup complete. Start the gateway" although nothing can route. Start from
False (only an opted-in number flips it) and give the no-phone path its own ending
naming the command that finishes setup.
2026-10-31 22:09:38 -07:00
Teknium
9bc94eb21d fix(photon): look up the iMessage line before the opt-in wait; skip the wait when there is none
A user row without assignedPhoneNumber started a 5-minute wait that told the user only
"text the line Photon assigns": the dedicated-line lookup ran after the wait. Look the
line up first; with still no line, skip the wait and say how to finish (text the line
once it shows up, then `hermes photon status`).
2026-10-31 22:09:38 -07:00
Teknium
d47a49d46c fix(photon): setup only says "complete" once the number can route; bound the opt-in wait
The opt-in step let setup end on "✓ Photon setup complete" even when the
wait timed out, was interrupted with Ctrl-C, or was skipped on a non-TTY
run, so the user was told to start the gateway for a number Photon still
refuses ("Target not allowed for this project").

- setup: when the number is not opted in, the closing line says the setup
  was saved but routing is NOT live, names the line to text, and points at
  `hermes photon status`; exit code stays 0 (config was written).
- wait_for_opted_in_user: add a wall-clock deadline next to the attempt
  cap, so slow list calls (30 s HTTP timeout each) cannot stretch the
  advertised 5-minute wait to half an hour.
2026-10-31 22:09:38 -07:00
Teknium
5d9b27cd23 feat(photon): gate setup success on iMessage opt-in via first message
Photon's delivery plane only routes numbers whose user row carries
meta.opt_in, and that flag is set server-side when the human sends ONE
message from their phone to the row's assignedPhoneNumber. A registered
row without it looks configured everywhere but never sends or receives:
outbound fails with 'Target not allowed for this project'. Client-supplied
meta is ignored on create, so the API cannot produce the flag.

- auth.py: user_opted_in(), find_routable_user() (an opted-in duplicate
  wins over list order; find_user_by_phone uses it, so setup re-runs and
  status refreshes reuse the routable row), wait_for_opted_in_user() poll
  (rides out transient list failures).
- cli.py setup step [4/5]: prints the assigned line to text and waits for
  the opt-in to land (Ctrl-C skips; non-TTY runs skip the wait).
- status: live 'routing' row (opted in / not opted in, with the line to
  text), emitted from auth.py like the credential summary.
2026-10-31 22:09:38 -07:00
Jeffrey Quesnelle
50d2adf1cd Merge pull request #146715 from NousResearch/fix/credential-stores-top-level
fix(secrets): move secret caches and the Photon token to the profile home root
2026-10-30 23:49:30 -04:00
emozilla
f413c2ee9a fix(secrets): delete old secret-store copies instead of moving them
The agent can write cache/ and runtime/, so a file there may be a link or a
forged record. Hermes now deletes a Bitwarden or 1Password cache in cache/, or
a Photon sidecar record in runtime/, on first use without reading it, and
reads and writes only the copy at the top of the profile home. All four stores
are regenerated on use.

- Remove utils.adopt_legacy_file and the paths built on it.
- home_data_layout: split SECRET_CACHE_STORES into SECRET_CACHE_FILES and
  LEGACY_SECRET_CACHE_PATHS.
- Backups leave out the four top-level names; the old slashed entries never
  matched a root entry.
- The dashboard Files API takes its hidden names from the shared list.
2026-10-30 13:46:07 -04:00
Ben Barclay
e924f75176 fix(redact): the log formatter reads no config
RedactingFormatter resolved a routed profile's redaction policy per
record from config, under the logging handler's lock. It now reads only
in-memory state: the live secret scope, and the policy recorded when that
profile's .env or config is loaded, or when log routing is set up for it
(resolve_profile_policy). Unknown means redact, the secure default.

This removes load_config_readonly_nowait() and the no-boot read scope.
2026-10-30 11:13:02 -04:00
Ben Barclay
8ae88edc8a fix(redact): the log formatter never waits for config
RedactingFormatter reads a routed profile's redaction policy from config
while holding the logging handler's lock. A thread holding _CONFIG_LOCK
(for example one booting a remote profile) that logs then waits for the
handler lock: a lock-order cycle. On the booting thread itself the read
re-entered the boot and ConfigBackendUnavailable escaped the formatter.

load_config_readonly_nowait() returns None instead of waiting: when
_CONFIG_LOCK is held by another thread, or when the read would start a
remote boot fetch (config_backend.without_boot()). The formatter then
redacts (the secure default) and does not cache that answer.

The remote backend's lock-order tests move to their own file.
2026-10-30 11:13:02 -04:00
Ben Barclay
96c029315b test(remote-config): cold-process Nous boot, config-free auth import, lock-order regressions 2026-10-30 11:13:02 -04:00
emozilla
2bed5b2258 fix(secrets): move secret caches and the Photon token to the profile home root
The Bitwarden and 1Password disk caches (bws_cache.json, bws_cache.enc.json,
op_cache.json) and the Photon sidecar runtime record (photon-sidecar.json) now
live directly in the profile home instead of cache/ and runtime/. A sandbox
that hides credential files by path can only hide them safely at the top of
the home: the agent can rename a folder it writes, such as cache/ or runtime/,
and read a hidden file below it at the new path.

The first read moves a copy from the old path with a rename, so the file keeps
its permissions. When both copies exist, Hermes removes the old one; when the
move fails, Hermes keeps reading and writing the old copy, so only one copy is
ever live. Clearing a cache or deleting the record removes both locations.

SECRET_CACHE_STORES in hermes_cli/home_data_layout.py lists these stores at
both locations, and every guard that keeps a list of credential stores uses
it: PROFILE_CREDENTIAL_PATHS (profile export and distribution), the file
tools' read and write denies, and the gateway's media-delivery deny. The
1Password cache was missing from all of them. The dashboard Files API blocks
the new basenames, backups leave the top-level stores out, and the flat-install
.gitignore ignores them.

A new test takes each store's path from its writer and checks that every guard
covers it at the current and the old location.
2026-10-29 22:21:46 -04:00
Teknium
f7641ace78 fix(web): pair a cached body with its own final URL; keyless Firecrawl reports its redirect target
The cache body and its final-URL annotation were separate writes, so two fetches of one key
interleaved as A-put, B-put, B-final, A-final left B's body validated against A's destination.
The index entry now records the body's sha256; the final-URL write is compare-and-set on it and
a hit is served only when the body on disk matches the entry it was recorded for.

The keyless Firecrawl path returned the requested URL and dropped metadata.url, so the shared
redirect gate never saw the destination. It now reports metadata.url (sourceURL = requested).
2026-10-28 13:54:02 -07:00
Teknium
6fc7c7dbf2 fix(web): Firecrawl re-checks the website policy against the URL it was redirected to
_scrape_one read metadata.sourceURL as the post-redirect URL, but Firecrawl
reports the REQUESTED url there (sourceURL on REST, source_url in the v4 SDK's
model_dump used by the direct-key and Tool Gateway paths) and the final URL as
metadata.url. The SSRF / website-blocklist re-check therefore re-checked the
requested URL, and a public redirector returned a blocklisted page.

Read the final URL from metadata.url, and fill sourceURL from source_url so the
extract cache still files a redirected page under the requested URL.

Found on Hermes Cloud staging.
2026-10-28 13:54:02 -07:00
Teknium
6696c7b0a4 fix(web): Exa and Keenable origin statuses never read as vendor throttling
Keyless Exa reports the target's status as CRAWL_HTTP_<code> / CRAWL_NOT_FOUND and
Keenable mirrors it as its own HTTP status with a "The target server ..." message.
Neither used the "HTTP <code> from origin" shape, so a site's own 429 walked the
keyless extract ring as if the vendor throttled us, and a 404 read as a vendor
failure with an API-key hint. Normalise both (keyless and keyed paths) into the
origin shape; Keenable's own rate limit and refusals keep the vendor wording and
still fail over.
2026-10-28 13:13:12 -07:00
Teknium
85af2bb438 fix(web): an origin HTTP 429 never walks the keyless extract ring
The new "HTTP 429 from origin" error matched the ring's rate-limit predicate,
so a site's own 429 failed over Parallel -> Firecrawl -> Keenable -> Exa and
returned Exa's error instead of the origin's. Origin errors are the page's
answer; vendor-side 429s still fail over.
2026-10-28 13:13:12 -07:00
Teknium
76911b77f2 fix(web): an origin HTTP 4xx/5xx never triggers the keyless extract rescue
The rescue exists for backend outages. A batch whose URLs all answered 404/410
is the pages' own answer, so re-fetching it through the keyless ring wasted a
request and contradicted _dispatch_extract's docstring. Origin-status errors
(the "HTTP <code> from origin" shape) are now excluded from the whole-batch
trigger; backend failures still trigger it.
2026-10-28 13:13:12 -07:00
Teknium
f7dde7f56d fix(web): web_extract reports a target's HTTP 4xx/5xx as an error on every extract provider
Scraping vendors answer 200 and report the target page's own status inside the
payload. Firecrawl (direct key, Nous Tool Gateway, keyless REST) put it in
metadata.status_code / statusCode and Hermes never read it, so
web_extract("https://httpbin.org/status/403") returned the stub error page
with error: null: the agent could not tell blocked from blank, the keyless
rescue never ran, and the error page was cached as content.

One shared helper in plugins/web/_common.py (origin_http_error /
with_origin_status / vendor_error_entry) now turns an origin status >= 400
into "HTTP <code> from origin[: reason]", keeping any error-page body as
content. Applied to:
- Firecrawl SDK/gateway scrape and the keyless REST scrape (both key spellings)
- Parallel keyed + keyless (error was the bare "http_error"; the payload's
  http_status_code was dropped)
- Exa keyed (URLs Exa could not fetch were silently missing from results;
  their reason lives in response.statuses)

Tavily, Perplexity and Keenable already surface per-URL failures (Tavily's
failed_results carry no status code).

Salvages the Firecrawl statusCode check from #99549 (and #99556), which read
only the camelCase key and only flagged empty content, so it missed the
Gateway/SDK case where the 403 body is a non-empty stub page.

Found on Hermes Cloud staging.

Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>
Co-authored-by: Ahmett101 <ahmet.tunc@gmail.com>
2026-10-28 13:13:12 -07:00
ethernet
780d5a3313 fix(auth): login surfaces share one interactive-provider query
Review follow-up (#146139). The native authorize route still counted
every session provider: with session-token beside one password/OAuth
provider an unnamed request 404'd instead of auto-selecting the only
interactive one, and with session-token alone (or named explicitly) it
fell into its start_login stub -> uncaught NotImplementedError -> 500.

registry.list_interactive_providers() is now the single query every
sign-in surface uses: native selection + chooser, the login page,
/api/auth/providers, auto-SSO and the /api/status native_pkce
advertisement (a token-only gate no longer tells Desktop to try a
browser flow it doesn't have). An explicitly named non-interactive
provider is rejected with 400 before any pending broker state exists.
The verify/refresh loops keep list_session_providers.

Tests: native authorize auto-select / token-only / explicit-name cases
and the native_pkce advertisement against the real routes (red without
the fix: the 404 and the 500 above); the dashboard.session_token_auth
opt-out read from a real config.yaml under a temp HERMES_HOME; the REST
bearer test now asserts an exact 200 + provider on /api/auth/me (the old
/api/session target was unrouted, so its 'not 401' passed on a 404).
Docs: the deployment check curls /api/auth/me, not /api/me.
2026-10-28 13:49:47 -04:00
ethernet
2edfd0d369 feat(auth): the deployment session token authorizes the gated dashboard
A token-only deployment (nix/agenix: backend.sessionTokenFile ->
HERMES_DASHBOARD_SESSION_TOKEN=file:<path>) had no way to satisfy the
June-2026 fail-closed gate: gated mode demands a registered
DashboardAuthProvider, the interactive prompt then writes basic-auth
credentials the deployment never asked for, and the provisioned token
itself is rejected on every gated leg (REST 401, /api/ws 403) — the
desktop's 'HTTP reachable but the WebSocket fails' incident.

The bundled session_token plugin closes that: it registers whenever the
session token is provisioned (skippable via
dashboard.session_token_auth.enabled: false) and verify_session
constant-time-compares the presented credential against it. Both legs a
token-mode client uses — the REST bearer path and the /api/ws ?token=
upgrade — run through that seam, so one provisioned token authorizes both.

It is deliberately not an interactive login: a new interactive_login
capability flag keeps it off the login page, /api/auth/providers, the
auto-SSO redirect and the native provider chooser (a token-gated /login
now renders a note explaining the credential channel), while
supports_session stays True so the gate's verify loops consult it.

Rotation semantics are pinned by tests: a saved client copy from before a
secret redeploy must fail closed, not half-work.
2026-10-28 13:49:47 -04:00
Teknium
714eab92e9 fix(config-remote): an explicit config set is stored even when it equals the inherited value
`hermes config set display.skin ares` with `ares` already supplied by an
upper level printed "Set ... in Remote Config" but sent no PATCH: the
document save diffed the key away as unchanged. A later upper-level
change then replaced the user's choice.

Keyed Changes.set and keys named in a new `pinning_keys()` block (the
CLI's `config set` document save) are now sent even when unchanged,
matching the file backend, which always writes them to config.yaml.
A key a lock already freezes is skipped, not refused.
2026-10-27 17:33:48 -07:00
Ben Barclay
748b71cef7 fix(config-remote): a configured URL's user info is never echoed in messages
destination.display_url() drops user:password@ from a URL (an unparsable one is cut at the last
@). The boot error, describe(), the user-layer provenance, the destination policy's own errors,
the redirect refusal and the IdP failure all show that form; the request itself still checks
(and refuses) the URL as configured.

Addresses teknium1's P3 (refused URL echoed with credentials) on #122509.
2026-10-27 17:33:48 -07:00
Ben Barclay
5da4eeb03c refactor(config-remote): backend.py uses diff.py's path helpers instead of its own copies
backend.py and diff.py each defined _set_path/_pop_path, and the two _pop_paths already returned
different things (None vs bool). backend.py now imports diff.py's pair; its callers ignore the
result, so only the duplicate goes.

Addresses teknium1's P2-3 on #122509.
2026-10-27 17:33:48 -07:00
Ben Barclay
f292c4c357 fix(config-remote): the poll interval is a constant, not a HERMES_* env var
HERMES_CONFIG_REMOTE_POLL_SECONDS is gone: the interval is 300 s (the 30 s floor stays), so no
new non-secret HERMES_* env var is needed before config can be read. A plane-served interval is a
later cross-repo change. The environment-variables reference now lists HERMES_CONFIG_REMOTE_URL
and HERMES_CONFIG_INSTANCE_ID next to HERMES_CONFIG_BACKEND, with why each must be env.

Addresses teknium1's P2-2 on #122509.
2026-10-27 17:33:48 -07:00
Ben Barclay
c0c74d20e4 fix(config-remote): serve main's ConfigBackend.cache_version from the remote backend
main (76f2fdb794, 5f02a8c19e) added cache_version to the ConfigBackend protocol and keys
every parse cache (load_config, the TUI raw read, profile reads) on config_cache_version.
The remote backend lacked it, so every cached read in remote mode raised AttributeError.
Its version is already exact (etag + local generation), so cache_version returns it
unchanged. Test: config_cache_version follows the remote version across a poll; without
the method 41 tests in test_remote_backend.py fail.
2026-10-27 17:33:48 -07:00
Ben Barclay
ac7e758c3d test(config-remote): the TUI outage test injects through hermes_cli.config_backend
baf3a751ca made tui_gateway.server._load_cfg_raw look config_version and
config_exists up on hermes_cli.config_backend (main's patch point), so
test_tui_raw_config_read_is_a_failed_read_that_refuses_to_save patching the
server module's names no longer reached the read (review round 2, CI
Python tests 2/2).
2026-10-27 17:33:48 -07:00
Ben Barclay
e4374020bd fix(config-remote): adapt the remote backend to the seam as merged in #134362
puts back what that build deliberately left for the remote backend, on
main's seam shape:

- RemoteBackend implements main's protocol (read_user_doc, probe_readable)
  and is not a FileBackend; _route returns (backend, home) and explicit
  files go through _ExplicitFile, so the is_layer branches are gone.
- One bootstrap: _ensure_bootstrap_env / bootstrap_deployment select the
  backend from the process env, the launch home's .env and the managed .env.
  #134362's _dotenv_backend_override did not survive its file-only refactor,
  so nothing stacks; its rules are now tests (stale shell remote + .env file
  boots file; empty .env value resets to file; .env-only remote selects
  remote; an absent key keeps the shell value).
- The file-tooling gates main removed (backup/import/snapshot restore,
  config edit, migration write-back, config backups, profile clone and
  distribution install, raw config editor, xAI migration, gateway --config).
- profile_serve_signature uses the backend version for config.yaml.
- restore_config_model_settings_if_rewritten is a no-op without file tooling.
- PM's dependency runtime reads a home's selection from the local file it
  publishes to (config_backend.local_file_layer), so a remote deployment
  never needs the plane there or fails PM closed.
- Ratchet: _container_slots/_validate_quoted_containers move to
  config_value_checks, _count_cron_jobs to backup_restore, the gateway
  --config load to gateway/config_loader.
2026-10-27 17:33:48 -07:00
Ben Barclay
d70ad6d86d fix(config-remote): review round 9d: custom-endpoint make-default refuses when its provider entry is locked
POST /api/providers/custom-endpoints with make_default and the activate route write
providers.<id> and the model route naming it in one document save. Only model.* was in the
refusing_locked_omissions scope, so a lock on providers (up front, or published before the save's
poll) silently dropped the entry while model.provider=<id> landed with ok=true; the runtime then
raised Unknown provider. The scope now covers model, providers and custom_providers on both paths
(HTTP 403, nothing saved). The CAS retry already refused through _patch_body's write_check.

Regression: test_custom_endpoint_make_default_refuses_when_its_provider_entry_is_locked
[locked, late-poll fail with the scope narrowed back to model; late-retry covers the retry path].
2026-10-27 17:33:48 -07:00
Ben Barclay
60c215db4c fix(config-remote): review round 9c: dashboard model saves keep the credential mask and refuse late locks
1. _resolve_assignment_credentials (POST /api/model/set) and the custom-endpoint make_default /
   activate paths replaced an inherited model.api_key with the target provider's key_env by
   popping it. Under Remote Config the block is the effective one, so the pop became a profile
   unset that cannot reach the upper level, and the inherited inline key (which outranks key_env
   at runtime) stayed active at the new endpoint. drop_model_key stores null for a key the
   effective block holds (file backend: plain removal), the same mask apply_model_selection uses.
2. remote_model_selection_guard is a preflight; a lock published after it was still silently
   omitted from the document save, landing a half route with ok=true. New
   config_backend.refusing_locked_omissions("model") scope: the remote backend's document intent
   raises ConfigLockedError (HTTP 403, nothing sent) when a lock it sees at save time covers a
   changed key under the scoped prefix. Wrapped around every whole-document model assignment save
   (dashboard main slot, profile builder, custom endpoint make_default / activate). The CAS retry
   already refuses a locked key through _patch_body's write_check.

Regressions:
test_dashboard_model_switch_keeps_mask_when_target_provider_carries_key_env (fails with the pop
restored), test_dashboard_model_switch_refuses_when_a_lock_lands_after_the_guard[poll] (fails
with the scoped refusal disabled), [cas-retry] (coverage of the existing retry refusal).
2026-10-27 17:33:48 -07:00
Ben Barclay
b8a41f7bf2 fix(config-remote): review round 9b: guard reads keep the caller's read base, dashboard model saves mask inherited route keys, MCP ack checks every toggle field
1. _write_config_state (atomic_config_write: /verbose, /footer, ...) runs its no-omission guard
   read under keeping_read_base, like save_config, so a poll between the caller's read and its
   save no longer becomes the base its stale document is diffed against.
2. Dashboard / profile model assignments (_apply_main_model_assignment: POST /api/model/set,
   profile builder, custom endpoints) share persist_model_selection's semantics under Remote
   Config: apply_model_selection(mask_cleared=True) stores null for a cleared key the effective
   block holds, and remote_model_selection_guard refuses the whole assignment when any changed
   model.* key is locked (a bulk save would otherwise omit it and land a half route).
   persist_model_selection now builds its keyed write from the same _merge_selection_updates.
3. profiles.configure MCP acknowledgement compares enabled AND the legacy disabled field per
   server, so a lock that kept disabled: true reports mcp_servers unapplied.

Regressions (each fails with the production change reverted):
test_poll_between_read_and_atomic_config_write_sends_only_the_callers_edit,
test_dashboard_model_switch_masks_inherited_endpoint_credentials,
test_dashboard_model_switch_refuses_whole_assignment_on_a_locked_route_key,
test_profile_editor_reports_mcp_unapplied_when_legacy_disabled_cleanup_is_locked.
2026-10-27 17:33:48 -07:00
Ben Barclay
b1bbb51e21 fix(config-remote): review round 9 blockers: read-based save diff, masked inherited route keys, honest editor acks, UTF-16 bootstrap parse
1. A document save is diffed against the base the saving context READ (per-context
   _READ_BASE recorded by read_user_layer / read_user_doc_readonly / version and after the
   context's own acknowledged write), not against whatever a poll installed between the read and
   the save. save_config's fail-closed guard read keeps the caller's read base. A poll before save
   no longer turns its changes into our unsets/sets with the current expectedVersion.
2. persist_model_selection (remote): a key the switch clears that the effective model block
   still holds is stored as null ("no value", contract 5.4), not unset at the profile level, so
   an upper-level old-endpoint api_key/key_env/api_key_env/context_length stops applying at the
   new endpoint. New config_backend.write_changes carries explicit nulls.
3. profiles.configure: skills / toolsets / MCP sections report applied only when the section
   reads back as written; a bulk save that dropped a locked key is no longer acknowledged.
4. _dotenv_assignments decodes UTF-16 (BOM) and strips NULs as the runtime sanitizer does, so
   stage2 / first-read selection agrees with the backend the runtime boots.

Regressions (each fails with the production change reverted):
test_poll_between_read_and_save_sends_only_the_callers_edit,
test_model_switch_masks_inherited_endpoint_credentials,
test_profile_editor_reports_a_locked_skills_edit_as_not_applied,
test_stage2_decides_like_the_runtime_for_utf16_dotenv[utf16-bom|utf16-no-bom].
2026-10-27 17:33:48 -07:00
Ben Barclay
f4c54cd3cc fix(config-remote): a config backend outage ends one request, fire or turn, never the process
andrexibiza P1-B. ConfigBackendUnavailable subclasses SystemExit on purpose: a fail-open reader
must never serve defaults instead of the selected backend's config, and boot fails closed. That
contract stays. But long-lived consumers caught only Exception, so a plane blip after boot killed
the thread (or, inside an asyncio task, stopped the gateway's event loop).

The six named sites, each with its own outcome:
- gateway/readiness._probe_config: the existence check moved inside the guard; the outage reports
  {"status": "degraded", "detail": "config backend unavailable"}.
- cron/scheduler._load_cron_job_config: still refuses defaults (its except Exception lets the
  outage through); run_job, the fire's owner, now catches it and returns that fire's failure
  result; _run_one_job_body records it like an Exception (mark_job_run(False), finish_execution,
  crash notice) instead of re-raising into the ticker.
- cron/jobs._main_model_pin (moved to cron/jobs_model_pin.py to keep jobs.py under its cap):
  raises ValueError, so pinned=True create/update is refused as invalid input instead of silently
  dropping the lock or exiting.
- tui_gateway/server._profile_configured_cwd: None (logged); the cwd is a hint.
- tui_gateway/server._load_cfg_raw: the designed FailedConfigRead; _refuse_failed_read now
  refuses to save it with "could not be read", not "formatting error".
- tui_gateway/prompt_attachments._profile_attachments_storage: "" (logged): attachments stage in
  the profile home the sandbox mounts and the vision allowlist cover.

The owners above every other config read on a long-lived path (sweep in the PR body):
- TUI request owner already answers 4064 (_handle_admitted_request); deferred agent-build and
  resume-hydration threads now report agent_error / the resume failure and release their waiters;
  compute_host turn and frame workers answer turn.error / their error frame.
- gateway platform turn (_process_message_background) notifies the user and ends the turn
  instead of re-raising this SystemExit into the loop; api_server gets an outermost
  config_unavailable_middleware (503) since entering a profile scope reads config; the served-
  profile reconcile watcher and _serve_profile_runtime park the profile for the next rescan.

Tests: tests/plugins/config_backends/test_remote_unavailable_consumers.py (13), each raising the
real ConfigBackendUnavailable from the seam the consumer calls; every production file's fix was
reverted alone and its test(s) went red.
2026-10-27 17:33:48 -07:00
Ben Barclay
5719daa071 chore(config-remote): meet main's ruff rules and the PR's config-reader gate after the rebase
The rebase onto main brought new lint rules (UP006/UP037/RUF100/RUF059/PLW1510/B009) that the
PR's own files did not meet, and main code that reads/writes config.yaml directly, which the PR's
reader gate (scripts/check_config_yaml_readers.py) refuses. No behaviour change in file mode.

- ruff --fix (safe fixes only) on the PR's files; explicit check=False / unused-name fixes in tests.
- gateway/session_config.py (new on main): the multiplexed 'mtime' getter uses config_version /
  config_exists, like tui_gateway's _cfg_get_mtime.
- hermes_cli/prune_advisor.py (new on main): decide() writes sessions.auto_prune through
  config_backend.write_config_key (a remote refusal is the existing "could not save" answer).
- hermes_cli/profiles.py _strip_multiplex_flag (new on main): config_exists, not Path.is_file().
- hermes_cli/config_backups.py / update_receipt.py: annotated as file tooling / pre-swap
  interpreter (both already gated on file tooling or run without the backend importable).
2026-10-27 17:33:48 -07:00
Ben Barclay
55805716e7 fix(config-remote): credentials go only to the configured https origin, never through a redirect
andrexibiza P1-A. The plane bearer (client.request) and the IdP client secret (_idp_token) were
sent to whatever HERMES_CONFIG_REMOTE_URL / GATEWAY_RELAY_IDP_TOKEN_URL held, over urlopen's
default redirect-following opener.

New remote/destination.py is a transport policy, not a host allow-list (D19 keeps the plane URL
operator-selected):
- https only; plain http only to localhost / 127.0.0.1 / ::1 (tests, local development);
- no user info, query or fragment in the configured URL (an ambiguous destination);
- credentialed requests use an opener with no redirect handler: any 3xx raises
  CredentialDestinationError instead of being followed.

The URL is checked before the bearer is resolved and before the IdP secret is encoded, so a refusal
sends nothing. CredentialDestinationError is a non-retryable PlaneCredentialError: boot fails
closed at once (no retry sleeps), writes refuse with config_plane_unreachable.

Tests (test_remote_credential_destination.py, 25): foreign ambient http origin, https->http
downgrade of the default, other schemes, userinfo/query/fragment refused before send with the
bearer never resolved; D19 default, on-prem https and loopback http allowed; real cross-origin
301/302/303/307/308 from a loopback plane and 302/307/308 from an IdP: the target listener sees
no request; boot through the real backend fails closed with zero plane/token requests. All 25
fail with client.py/credentials.py reverted.
2026-10-27 17:33:48 -07:00
Ben Barclay
d1ea2b7880 test(config-remote): wait on the bootstrap threads, not the clock (HX013 after rebase onto main) 2026-10-27 17:33:48 -07:00
Ben Barclay
2e36106171 fix(config-remote): config set/unset name Remote Config, not a config.yaml that is never written
With HERMES_CONFIG_BACKEND=remote the success line printed get_config_path() although the write
went to the plane's profile level and no local file exists. The backend now names its write
destination (ConfigBackend.destination); the file backend keeps the path byte for byte.
2026-10-27 17:33:48 -07:00
Ben Barclay
f15b518b25 fix(config-remote): review round 7 — grouped edits are one write, readers see only completed migrations
1. Grouped edits: new write_config_keys(path, {key: value}) sends related keys as ONE backend
   write (one CAS PATCH in remote mode), so a lock on any key refuses all of them.
   persist_model_selection, the TUI /focus setter and the thinking_mode setter use it; the TUI
   gets _write_config_keys (one raw round-trip save with the file backend). File-mode writes
   are unchanged (key by key, comment-preserving).
2. Migration reads: _postprocess has no single flight any more. A reader or writer that finds
   the published doc unmigrated runs its own private pass; the first to finish publishes
   (generation-fenced, st.postprocessed set only on publish). read_user_layer /
   read_user_doc_readonly snapshot only completed output (_snapshot re-completes when a poll
   lands in between), and write_changes prepares only against completed output. Waiting on the
   other pass instead could deadlock on _CONFIG_LOCK; private recursion is unchanged.
3. Docs: developer-guide/config-backend.md says the remote backend ignores the managed
   config.yaml while the managed .env still applies.
2026-10-27 17:33:48 -07:00
Ben Barclay
fd059c01f4 fix(config-remote): review round 4 — leaf-level CAS intent for new sections, D32 guard on routed secret-source hydration, config-only in-memory migrations, bootstrap completes before other threads select, project .env in the early bootstrap, keyed TUI section/prompt/consent setters 2026-10-27 17:33:48 -07:00
Ben Barclay
6dd799b30a fix(config-remote): review round 3 — intent-preserving CAS retry, private in-memory migration, poller roster snapshots, dotenv+managed bootstrap before the first read, deployment carried into routed children, remote-safe profile create/rename, backend-versioned roster cache, keyed TUI edits, RPC answers on backend refusal, stage2 uses the runtime's selection, refuse values a pending migration would rewrite 2026-10-27 17:33:48 -07:00
Ben Barclay
58504aab4a test(config-remote): vendor portal-groups fixtureVersion 2 conformance set; multi-group response, group lock and opaque ETag v2 regressions
- Re-vendor conformance/ from gateway-gateway 36dff9281f (gg #328): the 35 v1 files are
  byte-identical, plus the 12 multi-group fixtures of portal-groups contract §7.2 (each sha256
  checked against the contract table). APPROVED_FIXTURE_DIGEST e7e92b9b… -> 3fdf7068…
- The runner reads only profile writes, expect.locks[path, level] and defaultsMerge, so v2 needs
  no code change; a new check pins fixtureVersion to {1, 2} so a future format is reviewed.
- Stub plane can emit group levels, groupProvenance and lockedByGroupId; tests prove these are
  ignored, a group lock refuses client-side as lockedBy group, the plane's group 403 maps to
  ConfigLockedError + dashboard 403, and the ETag is echoed verbatim.
2026-10-27 17:33:48 -07:00
Ben Barclay
99e5ea1796 fix(config-remote): review round 2 — staged secret-source publication, generation-checked migration, plane value refusals
- env_loader: secret sources apply into a private staging copy of the
  environment; the D32 protected-name check runs before anything is
  published to os.environ, so a refused plane URL/credential is never
  visible to a concurrent request (the poller reads them live).
- remote backend: the doc's schema version and generation are captured
  together under st.lock; a migration whose doc was replaced before it
  starts (or at any step/commit) never touches the replacement.
- remote backend: plane value refusals (config_value_invalid,
  config_path_invalid/reserved, config_secret_literal, 413 too_large)
  become ConfigValueError; the dashboard maps them to 400/413 with the
  plane's message; config_request_invalid and others stay opaque.
- stub plane enforces the contract §11.1 depth limit; bulk-save test
  asserts the exact PATCH.
2026-10-27 17:33:48 -07:00
Ben Barclay
f0def49876 fix(config-remote): stamp writerConfigVersion only when the profile level's stored data is current
Contract §5.3 (absent = unchanged): an unrelated write from a newer agent no longer
re-stamps a profile level that still stores pre-migration keys, so later readers keep
running those migration steps (D12, R6). A newer stamp is never lowered. The stub plane
now honours 'absent = unchanged' too.
2026-10-27 17:33:48 -07:00
Ben Barclay
23b346f6cb fix(config-remote): review round 1 — boot selector latch, stale polls, migration diffs, dashboard refusals
1. Secret sources can no longer switch remote mode off. The backend is selected BEFORE
   apply_all and the protected-name check judges by that backend; HERMES_CONFIG_BACKEND is
   never a source's to set (reverted; remote mode exits, file mode warns and drops it).
2. A poll GET that a write (or a newer fetch) overtook is dropped instead of installed: every
   install bumps a sequence the GET captured when it started. profileVersion alone cannot tell
   (an upper-level change keeps it equal).
3. Writes diff against the doc readers got, i.e. migrated in memory (D12), also after the CAS
   re-read: an unrelated edit no longer sends the migration's unsets. A migration step for a
   doc a poll replaced mid-migration is dropped.
4. Dashboard: expected config refusals keep their message (lock 403, value 400, conflict 409)
   through http_failure; anything else stays an opaque 500.
5. Conformance: the fixture digest is pinned to a literal (contract §13.4).

Stub plane: deep_merge now ignores null over a mapping (contract §6.2); docstring says it is a
test double, not server-conformance evidence.
2026-10-27 17:33:48 -07:00
Ben Barclay
fa08fa90d0 fix(config): remote backend — no st.lock across migrations, re-arm poller after fork, classify poll refusals by status 2026-10-27 17:33:48 -07:00
Ben Barclay
69d037b349 feat(config): remote config backend (HERMES_CONFIG_BACKEND=remote)
plugins/config_backends/remote serves each profile's user layer from the
config plane: boot fetch inside load_hermes_dotenv with bounded retry and
fail-closed exit (D2), per-process ETag poller (D9), key-level diff writes
with CAS and one conflict retry (D10), client-side lock and secret-literal
checks (D7, D17), in-memory migrations (D12), managed config.yaml ignored
(D18), plane credential from auth.json or IdP client credentials only and
never from a secrets: source (D26, D32). Vendored gg conformance fixtures
run against the lock matcher, secret rule and _deep_merge.
2026-10-27 17:33:48 -07:00
Teknium
2a8413a52e fix(webapp): self-hosted sign-in admits whom it admitted on main, each as the machine owner
Maintainer ruling: an owner restriction on self-hosted OIDC adds no real protection, because
anyone the login provider lets in already gets the agent and terminal as you on main. Remove the
first-sign-in owner pin (owner_pin.py, dashboard-auth/self-hosted-owner.json) and the
dashboard.oauth.self_hosted.owner check; the self-hosted provider is back to main's code. Who may
sign in is decided by the login provider's app configuration, and the docs now say so.

The hosted-room daemon test signs in two different IdP accounts again (as on main); both act as
the owner and share one Group Chat list.
2026-10-27 17:32:49 -07:00
Teknium
8497ce9318 fix(webapp): a signed-in Webapp tab is the machine owner, the same identity native Desktop uses
Hermes is single-user (maintainer ruling): sign-in only gates whether a browser may open the
Webapp, it never creates a second identity. Every login (Webapp tab, loopback session token,
a dashboard login forwarded by a standalone backend, the dashboard's PTY child) now acts as the
host owner's OS subject (uid:<n> / sid:<sid>), on both routes:

- gateway route: AuthorityConnection and the REST session-mutation context build the principal
  through gateway.owner_identity.principal_subject.
- tui_gateway route: rows a login creates over hermes serve carry the owner subject instead of a
  <provider>:<user> label, so native Desktop and the TUI resume them.

Stored login stamps from older builds read as the owner's (read-time, nothing rewritten or
deleted): auth:v1 room owners and history bindings, and <provider>:<user> labels of a bundled or
registered dashboard sign-in on routeless local rows. Messaging ids (telegram:42), other OS users
(uid:N) and nous: stamps on non-Desktop rows stay foreign.

Owner-only sign-in: basic auth has one account and the Nous Portal refuses other accounts for the
registered agent client; self-hosted OIDC admitted every IdP account, so it now admits one:
dashboard.oauth.self_hosted.owner, or the first account to sign in, pinned in
dashboard-auth/self-hosted-owner.json.
2026-10-27 17:32:49 -07:00
unsupportedpastels
074d150fab fix(dashboard-auth): print the ignored basic-auth secret notice once on stderr
The error for a signing secret holding shell text only reached agent.log and
errors.log, so an operator watching the console of hermes serve or hermes
dashboard saw nothing and was only signed out on every restart. Print one line
on stderr the first time such a secret is ignored in a process. The line names
the setting and the fix but never the configured value.
2026-10-27 16:37:10 -04:00
unsupportedpastels
0323a30052 fix(dashboard-auth): treat a pasted openssl rand command as an unset basic-auth secret
The basic provider already ignores a signing secret holding $( or a backtick.
A secret that is the command itself (openssl rand -base64 32), a spaced
"$ (...)", or the web-dashboard.md placeholder
"<32+ random bytes; openssl rand -base64 32>" pasted as-is was still used as
a fixed, known key. Also match "openssl rand": base64 and hex output never
contains a space, so no generated secret can match it.
2026-10-27 16:37:10 -04:00