Commit Graph

238 Commits

Author SHA1 Message Date
Teknium
765933299d fix(compression): a prepared summary is never redone over a moved tail cut
With compression.prepare_ahead, compress() re-planned the tail cut and threw the
completed background summary away whenever the fresh cut landed before the
summary's boundary (the no-LLM prune made tail rows cheaper, tool-group
alignment moved the cut), then wrote a second summary inline while the user
waited. That breaks the one-summary rule: once the background summary exists it
is used, and everything after its boundary is the tail.

The splice check no longer consults the fresh cut at all. A summary is still
discarded only when the messages it covers changed (rewind, shape change, other
session, moved head). The pass planned its own window with a full tail, so the
tail is never empty. The now-unreachable inside_tail reason leaves the
(unreleased) prepared-compaction metric contract.
2026-10-26 00:10:23 -07:00
Teknium
0107da5d2a fix(telemetry): the pre-os._exit flush drains the root profile's host-count store too
Follow-up to #144850. flush_before_hard_exit drained only the per-profile
runtime stores, so a deferred write to the root (default) profile's store,
where the host-level active-profiles accumulator lives and which no runtime
owns, was still lost at every graceful os._exit (gateway, compute host,
kanban worker, slash worker).

Each SharedMetricsStore now registers itself in a process-level list the
first time it defers a write (next to its atexit drain), and the bounded
exit flush drains that whole list within the same budget. Each deferred
write runs against the store that deferred it, so no profile's rows land
in another's database; collection off creates no store, so nothing is
registered.
2026-10-25 23:30:24 -07:00
Teknium
23cf609b38 fix(telemetry): deferred store writes survive contention into the bounded exit drain
Review finding 4 on #144850. A store another process held past the 250 ms
busy timeout deferred the exit rows, then the export's drain_deferred dropped
them on the same contention, and os._exit skipped the store's atexit drain.
drain_deferred now re-queues on a busy/locked store (the _write_or_defer
promise), and flush_before_hard_exit drains every live store within the
remaining budget, so contention that clears inside the 3 s bound no longer
loses the open sessions' rows.
2026-10-25 23:13:53 -07:00
Teknium
b991bd203b fix(telemetry): exit flush applies each profile's own send consent and collection gate
Review findings 1 (critical) and 2 on #144850, plus the send-pass sibling.

A multiplex gateway or compute host exits from the launch profile's scope, and
the os._exit flush (like main's atexit hook, which has the same flaw) shut down
every profile's runtime under it: profile B (send: false) got the launch
profile's send=True reconciled into its store, an open-ended consent window and
a send pass over its outbox; a profile that turned collection off since its last
turn still had its open sessions written at exit.

- _Runtime.shutdown binds its own profile home (host.profile_key) for every
  caller (atexit, shutdown_runtimes, tests) and checks enabled() inside that
  scope first: a revoked runtime is deactivated, dropping its data unexported.
- _flush_and_export exports under the owner's scope, whoever triggered it.
- The send pass thread inherits that scope (spawn_context_thread): on main it
  ran on a bare Thread, so still_consented() re-checked the LAUNCH profile's
  consent (B's pass read A's send:false; a B revoke would not stop its pass).
- Tests: wait_until replaces the sleep-poll; one three-profile invariant test
  through the real gateway exit funnel.
2026-10-25 23:13:53 -07:00
Teknium
6e5ebd7a76 fix(gateway): flush opt-in shared metrics before the graceful os._exit
Every graceful gateway stop (SIGTERM, update restart, idle exit, --replace takeover)
funnels through _exit_after_graceful_shutdown, which ends in os._exit and so skips the
shared-metrics runtimes' atexit hook. Sessions still open at the stop (a messaging or
Desktop chat) never closed, so their hermes.session.count / context-peak / tool-usage
rows never reached the local store.

shared_metrics_process.flush_before_hard_exit runs that hook's work (shutdown_runtimes)
on a daemon thread joined for at most 3 s, never raises, and never imports the runtime
module, so with collection off nothing is created. The gateway runs it first, before
the PID/lock release.
2026-10-25 23:13:53 -07:00
Teknium
d773589f7c fix(compression): every prepared summary ends counted as used or discarded
Re-review findings:
- a summary take() handed to compress() that the compaction then aborted or no-opped before
  adopt() spliced it was counted nowhere; it is now counted once at the next touch as
  discarded/compaction_aborted;
- a session boundary landing after the pass published but before the waiting compaction woke
  read as a failed pass (a second discarded row); the wake now reads the entry and the cancel flag
  under one lock, so the boundary's row is the only one.
2026-10-25 22:55:11 -07:00
Teknium
5bdf1de16f fix(compression): count each prepared summary once, at the splice
Independent review of the telemetry found:
- a session boundary that woke a waiting compaction was counted twice (the boundary's discard
  plus the woken wait's 'discarded_while_waiting'); the boundary's row is now the only one and the
  dead reason code is dropped from the vocabulary;
- 'used' was recorded in take(), before a stale-attempt abort could still drop the summary; it is
  now recorded by adopt(), the splice itself, with the wait carried on the entry;
- the cancel reason is set under the lock, so a pass finishing in that gap reports the real reason;
- skipped_busy counts once per refused window instead of every tool batch.
2026-10-25 22:55:11 -07:00
Teknium
77af0690a8 fix(compression): one-shot runs start no wasted pass; releasing an agent cancels its pass
The live matrix on real processes found two ways a prepared-compaction pass was paid for and never
usable:

- `hermes chat -q` / `-z` runs end with their turn (the gateway evicts the agent right after the
  reply), so a turn-end pass there was always cancelled ~0.5 s later. One-shot sessions now join
  cron runs and delegated children in skipping turn-end passes.
- Releasing an agent without a session boundary (gateway cache eviction, a Desktop rewind,
  managed-worker retire, close()) left a running pass billed to completion. release_clients() and
  close() now discard it (shared-metrics reason `agent_released`).

Pass log lines now carry the session id, so concurrent sessions in one gateway are attributable.
2026-10-25 22:55:11 -07:00
Teknium
4ea24baeb1 feat(shared-metrics): count prepared-compaction adoption and outcomes
Opt-in shared metrics could not say whether anyone turns on
compression.prepare_ahead, or whether the passes it starts pay off.

- hermes.install.snapshot gains compression_prepare_ahead (on/off), read
  from the profile config with the agent's own truthiness. Pre-upgrade
  snapshot rows keep a legacy field set and the v4 schema field is
  optional, so they still validate and package.
- New closed-enum counter hermes.prepared_compaction.count (mark name =
  metric name, projected by the decision-mark table): event, origin,
  reason, failure_class (compression vocabulary), wait_bucket.
  record_prepared_compaction() takes raw values, normalises inside, is a
  no-op unless collection is on and never raises.
- Vocabularies live in shared_metrics_prepared_compaction.py (the
  contract sits at the 2,000-line cap); the contract imports it.
- v4 schema extended in place (additive), docs row + snapshot bullet,
  relay smoke asserts the snapshot field.
2026-10-25 22:55:11 -07:00
Teknium
65ee955417 fix(telemetry): keep process marks from background work that outlives its turn
A thread started with the turn's contextvars (spawn_context_thread, copy_context) still holds that
turn in relay_runtime._CURRENT_TURN after end_turn closes it. relay_instrumentation_enabled() reads
False for a closed turn, and record_process_mark / record_process_marks_saved / the
post_auxiliary_call hook returned on that gate before emitting anything. So every process-level
mark such a thread recorded after the turn ended was dropped silently: aux-token rows from title
generation finishing late, and any decision mark a turn-end background job reports when it is done.

The closed-turn check (e1caa611bf) stops new Relay scopes being pushed under a finished turn. A
process mark has no owning task and pushes no scope, so a closed turn now no longer gates it. A turn
Relay skipped (a concurrent turn on the same session) still gates, open or closed, as before.
Scope-creating hooks (task, model call, tool) keep the full gate.
2026-10-25 22:28:13 -07:00
Teknium
b87977cadd refactor(api): remove browser-extension control (its browser tools are gone)
The broker's capability allowlist named only the deleted browser_navigate/click/type/... tools, so a
bound extension controller silently did nothing (review P1-1); owner ruling: remove the feature.
Drops the broker, artifact store, extension router, /v1/browser-control + /v1/artifacts routes,
browser.controller.* RPCs/events (contracts regenerated) and the per-request controller identity.
The authenticated-identity helpers bot relay and session ownership still use move to
gateway/session_identity.py; persisted API admissions carrying 'browser_control' still recover.
2026-10-23 01:42:27 -07:00
Teknium
9f5b563119 refactor(browser): integration residue — locale prune, launcher lookup via hermes_platform, browser_exec metered
- locales: drop the /browser use, Browser Use mode and agent-browser status keys whose callers are gone;
  reword status/usage/description lines and tips t180-t182 (contiguous tip keys kept) in every locale.
- browser_launcher: a bare command name in browser.executable_path resolves through hermes_platform's
  locate_command (no shutil.which); the LANE fallback for chromium_missing_hint is gone.
- browser_cdp: drop the Camofox sentences from its description and error.
- shared metrics: record_browser_call loses the extension-controller wrapper (no browser_* tool routes
  through it any more) and browser_exec's registry handler calls it, so the browser execution-backend
  series keeps reporting for the only browser path.
- test_profiles: the clone/live-browser test uses browser_launcher.running_instance.
2026-10-23 01:41:25 -07:00
Teknium
e1b65c5f0b refactor(browser): callers stop naming agent-browser, Camofox and the built-in browser tools
- hermes acp --setup-browser installs pm's chromium (browser_exec's local
  browser), not agent-browser;
- the codex hermes-tools MCP server stops exposing the deleted browser_*
  tools (browser_exec stays out: it runs model-written Python outside
  codex's sandbox and approval UI); /codex-runtime copy follows;
- telemetry: the removed tool names become RETIRED_TOOL_NAMES so the shipped
  schema enums keep them; camofox stays a legacy browser backend label;
- CLI config defaults drop browser.camofox / record_sessions (the camofox
  plugin reads browser.camofox itself);
- learn prompt names browser_exec; stale comments and help text updated.
2026-10-23 01:41:24 -07:00
emozilla
d7c48548a9 feat(shared-metrics): offer two consent answers, drop collect-only
The first-run offer on Desktop, the dashboard and the terminal had a
third answer ("Keep on this computer" / "Collect locally only" / "Local
only") that collected stats nobody reads: no surface shows them to the
user, and data from before an opt-in is never sent. Every surface now
offers "Share with Nous" or "No thanks", and each answer sets `enabled`
and `send` together. Desktop Settings > Privacy and `hermes setup
telemetry` become one on/off choice to match.

Profiles that already chose collect-only keep that answer and are not
asked again: they saw the question and declined to send. Nothing is sent
for them; the Desktop switch reads off and the `hermes tools` row says
"collecting locally".

Copy that described collection as a separate local choice is rewritten
in every locale that carries it (de, es, fr, ja, ru, zh, zh-hant, ar).
2026-10-21 00:32:21 -04:00
ethernet
0c864cebfb feat(shared-metrics): Microsoft Store installs report their own install_method
The Store build was indistinguishable from other desktop installs in opt-in
metrics: detect_install_method() has no word for it (it reads "unknown"), and
the update-run path flattens microsoft-store into apply_mode=package.

Add "microsoft-store" to the closed install_method enum (contract + v4 schema,
additive) and report it from the install stamp's updateMechanism. The mapping
lives in shared_metrics_install.detect_client_install_method, not in
detect_install_method, because update and uninstall branch on that function's
result and must not learn a new value.

Every metric already carries install_method on its resource block, so this
gives a Store slice of all of them (client_active, desktop onboarding, ...).
2026-10-16 17:47:11 -04:00
Teknium
0715474bfd Merge origin/main into feat/unified-gateway-runtime
375 commits from main (0e427d788d). 24 files conflicted; the resolutions that carry a decision:

- /initiate-setup: main removed the command (25bf722063). Its gateway rewrite, CLI handler and the
  Desktop kickoff go with main; this branch's command-layer admission of it is dropped too
  (gateway/session_commands.py _PROMPT_COMMANDS, its slash.exec test row, the parity doc row), and
  the Desktop slash dispatcher loses the `hidden` option that only the kickoff used.
- Code this branch moved out of its old file, carrying main's edits to the moved copy:
  first-contact notes (gateway/run_turn.py -> run_turn_prepare.py: no message/setup_command),
  the TUI agent factory (tui_gateway/server.py -> agent_factory.py: onboarding toolsets at build,
  setup_beat/set_theme lifecycle cards, no cli platform extras on a coding selection), the serve
  lifespan (web_server.py -> web_server_app.py standalone_lifespan: first-install probe before the
  state.db reconcile, onboarding due answer after the setup bootstrap), and the compression child
  publish (the shared _publish_compression_child_on_conn reads the parent's model_config).
- agent/auxiliary_client.py: both import changes (_route_key from main; this branch's move of
  _without_structured_output_format).
- Desktop: main's onboarding run (decideOnboarding, OnboardingEnd, card-waiting Send) replaces the
  kickoff; this branch's prepared-submission slash path, request_id on session.create and
  PreparedImageRecovery stay. Pool-limits imports are dropped (this branch removed the pool).
  createBackendSessionForSend takes main's (preview, overrides) signature.
- ci.yaml detect job: main's `ref: inputs.commit` plus this branch's sparse checkout.
- package.json / lock: main's vitest 4.1.11 plus this branch's ws 8.21.1.
- Generated: gateway-contract.openrpc.json regenerated; parity doc regenerated.
2026-10-14 05:52:49 -07:00
Siddharth Balyan
56b10be733 feat(metrics): count connector file-input refusals by error class
A refused path counts as not_allowed, a missing or oversized file as
invalid_arguments, and a failed upload as connector_backend.
2026-10-14 02:14:52 +05:30
alt-glitch
df6895a853 fix(telemetry): rows saved with the retired setup names still package
Shared-metrics v4 only adds values. Rows that v0.21.6/7 saved with
toolset=setup/start_chat (tool_enabled_unused) or tool_name=setup_choose/
start_chat (tool.usage, tool_unavailable) failed contract validation once
the setup tools were deleted, and one bad row aborts the whole package.
The contract accepts RETIRED_TOOLSET_NAMES and RETIRED_TOOL_NAMES again and
the v4 toolset enum lists setup and start_chat again; recording still maps
through the live sets.
2026-10-14 00:29:12 +05:30
alt-glitch
4142c9eeab revert: no compatibility for the retired setup tool names
Saved telemetry rows naming setup_choose, start_chat or the setup toolset
are no longer accepted for upload, and old configs that list the setup or
start_chat toolsets now get the usual unknown-toolset warning: the old
setup flow is deleted without compatibility.

The v4 metrics schema keeps 5730df8165's change (the two toolsets leave
the schema enum), so the schema and the contract's toolset values still
agree.

This reverts 411c6ebee3 and the retired-toolset acceptance in
validate_toolset that 5cfd1437dd added, with its test.
2026-10-14 00:29:12 +05:30
alt-glitch
b18d304d54 fix(telemetry): saved rows naming the retired setup tools still package
Deleting the setup tools shrank BUILTIN_TOOL_NAMES and BUILTIN_TOOLSET_NAMES,
which the package builder also uses to validate saved rows. A pending row
naming setup_choose, start_chat or setup then raised in _package_metric, and
the oldest pending batch blocked every later export. The accepted metrics
vocabulary now unions RETIRED_TOOL_NAMES / RETIRED_TOOLSET_NAMES and the v4
schema lists them again; recording still maps through the live set.

Adapted: main's metrics contract now also counts the Tool Search bridge and connector names as live tool names; the retired names join that set.

(cherry picked from commit 304cb0c87e72d65df0e3fd25e68accfe149f3bfc, adapted)
2026-10-14 00:29:11 +05:30
alt-glitch
984c9b09d9 fix(telemetry): the v4 schema drops the retired setup and start_chat toolsets
Rung: #135193
Deleting the setup and start_chat toolsets removed them from
BUILTIN_TOOLSET_NAMES, so the contract's tool_enabled_unused toolset values
no longer matched the v4 schema enum
(test_v3_schema_accepts_exactly_the_contract_values).

(cherry picked from commit 12e7f705033a661a7800417914b1de5dae478a31)
2026-10-14 00:29:11 +05:30
alt-glitch
d8cefac352 feat(onboarding): setup_beat, the one onboarding-only tool
tools/setup_beat_tool.py shows a beat's card and blocks until the user
answers (the card callback is a server request, like clarify), then
returns their answer with a reminder of the next beat. beat=next shows
the first open beat; value and skip record an answer given in words
without a card; beat=done ends the run once the build card was reached,
and beat=done with skip=true ends it early when the user asks to stop.
Words typed while the name card waits are the name. The account's full
name goes to the name card only.

The tool lives in a new desktop-only "onboarding" toolset, which nothing
enables by default; the gateway folds it in for the onboarding chat only
(next commit). It runs inline in the agent loop (inline_tool_executors)
with the session's store and the agent's setup_beat_callback, and never
in parallel with another tool.

Two loop seams:
- tool_executor passes every successful tool result to
  onboarding.observe_tool_result, so set_theme, manage_connections
  display and gui_tour (also when reached through tool_call, which the
  executor unwraps first) settle their beat.
- turn_tool_round treats a setup_beat round like a housekeeping round
  for the empty follow-up: the line written with the card becomes the
  reply instead of an empty-response nudge (not muted).
2026-10-13 22:08:20 +05:30
Teknium
2cd0ec8686 Merge origin/main into feat/unified-gateway-runtime
215 commits from main (c70332f888). One textual conflict: the generated
apps/shared/src/gateway-contract.generated.ts, regenerated with scripts/gen_gateway_contracts.py
rather than hand-merged. Brings main's fix for the dated shared-metrics install-receipt test
(783637e370).
2026-10-13 05:15:48 -07:00
Teknium
10a877bc9e fix(telemetry): install receipts age on the store's clock, not wall time
_stale() read time.time() while the rest of the install-run reporter reads
the store's _utc_now(). The consent-day test pins the store clock to
2026-10-06 and parks a receipt finished then; once real time passed
2026-10-13 09:00 UTC (7 days, MAX_RECEIPT_AGE_SECONDS) the receipt expired
on wall time mid-test and main's Python tests went red on every PR.

One clock for the whole module. Production behaviour is unchanged
(_utc_now is datetime.now(UTC)).
2026-10-13 03:31:04 -07:00
Teknium
0438ca2da5 fix(telemetry): retired built-in values stop wedging the package too
The re-bucket only knew catalog drift (custom/other buckets), but code
constants drift as well: 71704ffb49 moved Spotify out of core after v0.21.6
shipped, so a v0.21.6 row with toolset=spotify or tool_name=spotify_search no
longer passes the contract, and v0.21.7 aborted every package behind it.

- The fallback bucket is the first of custom, other, unknown the field defines.
- A field with no bucket at all (tool_unavailable's tool_name) leaves that one
  row out instead of aborting the period; the stale value is never exported
  either way, and an unknown field set still fails closed.
- Rows a re-bucket folds onto the same dimensions merge into one metric, and a
  period whose every row was left out settles without an empty package
  (the schema needs at least one metric).
- The drift notes log at info, not warning, so they never reach the console.

The two helpers live in a new shared_metrics_drift.py sibling: the contract module
was over its 2,000-line cap with them.

Tests: the contributor's catalog test stays; the two fail-closed tests become
one invariant for the retired-value case (merge, leave out, settle), red on
origin/main.
2026-10-13 00:52:16 -07:00
liuhao1024
a1d8264f09 fix(telemetry): re-bucket catalog-drifted shared-metric rows instead of aborting the package
One counter row whose values fell out of the contract raised inside
_create_package_in_transaction and aborted the whole period's package:
every shared metric in the period failed to export and the agent crashed
at exit (#133017).

Record-time validation passes catalog-backed values against the recording
process's catalog snapshot, but the catalogs are repo data that move with
every update: a plugin installed from the catalog while it listed the
name stores a row that a later run (with the entry removed upstream)
rejects. The field set of such a row still matches the contract exactly;
only a value left the closed enum.

Split the packaging check in two: an unknown field set is tamper evidence
and keeps failing closed (test_package_builder_rejects_tampered_dimensions
unchanged), while a known shape with out-of-enum values is re-bucketed
into the field's own custom/other fallback before export — mirroring what
the record-side normalizers do for names that were never catalog entries.
Values that cannot be re-bucketed (enums without a fallback bucket,
identifier fields that no longer round-trip, non-strings) still fail
closed.
2026-10-13 00:52:16 -07:00
Teknium
a89f374d7c Merge origin/main (#45: 255 commits to 3b63f7b0a4) into feat/unified-gateway-runtime
Conflicts (2 files, 1 hunk each); every main-side change is kept, ported to
where the branch moved the code:

hermes_cli/kanban_db.py (build_worker_context helpers _ctx_cap .. _ctx_comments)
  main:   f5a6651231c/d56e357556f coerce foreign/text timestamps on read; in
          _ctx_role_history the "Recent work" stamp became
          _ctx_stamp(_to_epoch(row['ended_at']) or 0, now) instead of int().
  branch: moved the whole _ctx_* helper block into hermes_cli/kanban_db_context.py
          (kanban_db.py imports it back), deleting it from kanban_db.py.
  merged: kept the branch's deletion in kanban_db.py and applied main's change in
          kanban_db_context.py::_ctx_role_history as
          _ctx_stamp(_kb._to_epoch(row['ended_at']) or 0, now). Main's other
          timestamp coercions in kanban_db.py (Task/Run/Comment/Attachment/Event
          from_row, _TASK_EPOCH_COLUMNS, release_stale_claims,
          _extend_live_stale_claim, task_age) auto-merged unchanged.

hermes_cli/web_server.py (_lifespan)
  main:   d7830c6f42 reworded one comment in the free-tier bootstrap block
          ("the ONE place its identity is created" -> "the one boot-time creator
          of its identity"; guests are now also created on first connector use).
  branch: moved _lifespan's body into hermes_cli/web_server_app.py::app_lifespan.
  merged: kept the branch's relocation and applied main's comment rewording in
          web_server_app.py.

Merge-induced health fix (no conflict marker; the combination tripped the ratchet):
apps/desktop/src/app/session/hooks/use-cwd-actions.ts::changeSessionCwd
  main:   63ed3caa4ba/dbc538547fc grew the function (statusbar cwd change for the
          focused chat / tile runtime ids) to CC 20.
  branch: added the session_busy refusal mapping (sidebar.projects.moveBusy) in
          its catch, +1 branch -> CC 21 > target 20 (scripts/check health blocking).
  merged: both behaviours kept; the busy-error mapping moved verbatim into a
          module-level cwdChangeError(err) helper. Health back to 0 blocking.

Check: every line main added between 1fd1827726 and 3b63f7b0a4 (317 files) is
present in the merged tree.
2026-10-12 16:55:20 -07:00
Siddharth Balyan
bb9458214e fix(shared-metrics): an abandoned connector batch counts its started entry once
Review: when the executor timed out during a batch's first entry, the entry
never posted, so the wrapper's post found no counted entry and was counted
as its own call while the entry's open span was closed again at task end.
A wrapper now closes its still-open entries with its own outcome and is not
counted on top; a batch refused before any entry started still counts once.
2026-10-13 01:35:42 +05:30
Siddharth Balyan
242439977b fix(connectors): batch entries dispatch under their own call ids
Review: entries shared the wrapper's tool_call_id, so a trace plugin folded
them into one observation and an approval on an entry found no open call.
Each entry now dispatches as <id>#<position> (hooks, approval context and the
gateway's tool-call header), the metrics runtime keys on those real ids, and
the post-hook toggle folds into suppress_post_tool_call_hook(False). The
connector chain state rides the compression lineage, and tool_describe names
are read the way its dispatcher reads them (bare string, stripped).
2026-10-13 01:35:42 +05:30
Siddharth Balyan
eaff548aec refactor(shared-metrics): class connector errors from the wire's execute families
Backend-family codes come from tools.connectors.gateway.wire (EXECUTE_ERROR_CODES via
execute_error_family) instead of a second copy of the code table; the contract keeps
only the product-code classes, pinned to the wire table by a test.
2026-10-13 01:35:42 +05:30
Siddharth Balyan
eb2edce53a feat(shared-metrics): emit tool_search, tool_batch and connector_chain rows
tool_search: one row per search with the catalogs read, a hits bucket and the
outcome. tool_batch: one row per model reply that calls tools, counting each
tool_call entry. connector_chain: one row per executed connector entry with the
searches since the last execute and whether the tool was described first.
2026-10-13 01:35:42 +05:30
Siddharth Balyan
c71fb6f161 fix(shared-metrics): count each connector batch entry once, not the batch
A tool_call batch fired a post_tool_call per entry plus one for the wrapper,
all under one tool_call_id, so the runtime kept whichever came first: one row
per batch. In the sequential executor the entry posts were suppressed, so the
row named the wrapper. Entries now report their own post, get distinct
identities, and the wrapper is dropped once an entry was counted.
2026-10-13 01:35:42 +05:30
Siddharth Balyan
93087615db feat(shared-metrics): name connector work in the v4 tool taxonomies
Connector calls read tool_name and tool_category "connector" (never the slug),
the Tool Search bridge tools keep their own names, and a failed connector entry
is classed by the gateway error code in its result. Adds the closed sets for
hermes.tool_search.count, hermes.tool_batch.count and
hermes.connector_chain.count. Additive inside package schema v4.
2026-10-13 01:35:42 +05:30
Teknium
837f50b3da Merge origin/main (#36: 11 commits to a62979dc36) into feat/unified-gateway-runtime
One conflict: agent/context_compressor.py imports. Main's a62979dc36 dropped the
now-unused _safe_int import; the branch's retryable_user_text import is kept.
2026-10-10 08:36:16 -07:00
kshitijk4poor
760c93fef7 fix(shared-metrics): count an empty-transcript refusal under its own class
#135807 makes the empty-transcript refusal emit its attempt record through
the shared-metric lifecycle (on main that exit recorded nothing), but
`empty_transcript` was not in the closed `COMPRESSION_FAILURE_CLASSES` set,
so the `hermes.compression.count` row read `failed / other`. Add the class
to the contract, the v4 package schema enum and the metric docs so the row
says what happened.
2026-10-10 20:18:10 +05:30
mnajafian-nv
a7445c5081 fix(shared-metrics): limit bench alias to committed rows
Keep aborted attempts' existing classification when the summary model was
benched. The new regression case proves the failed row remains other while
a committed fallback still maps to feasibility_skip.

Signed-off-by: mnajafian-nv <mnajafian@nvidia.com>
2026-10-10 20:18:10 +05:30
mnajafian-nv
0a81c37ed0 fix(shared-metrics): keep a committed fallback's class on hermes.compression
finish_compression_attempt reported every committed attempt as
outcome=success with failure_class=none, so the metric could not tell a
clean summary from a commit that went through a fallback: a
deterministic summary (summary model failed, pre-LLM feasibility skip,
repeated stall, sustained overload) or the main model writing the
summary after a separate summary model failed.

A committed attempt still reads success (it did commit and break the
prompt cache), but now keeps the attempt log's own class when it has
one: summary_generation_failed, feasibility_skip,
stall_deterministic_fallback, summary_overload_degraded or
aux_model_fallback. summary_model_benched, the deterministic commit after
the summary model is benched for repeated fallbacks, maps to
feasibility_skip, which is the pre-LLM skip it is. Any other class reads
other.

No new enum values, so the v4 package schema is unchanged and a fallback
row still validates. Consumers that read failure_class != none as a
failure must now also check outcome: on a success row it means
"committed with a fallback".

Signed-off-by: mnajafian-nv <mnajafian@nvidia.com>
2026-10-10 20:18:10 +05:30
Teknium
cfaafec502 Merge origin/main (#35: 133 commits to f925b01791) into feat/unified-gateway-runtime
Three conflicts:
- apps/desktop/electron/updater/checkout-source.test.ts: main's 354fe11d7e is the
  same releases/latest fixture fix this branch carried as c300c295c1 (#135944); main's
  version (it also drops the unused release-candidates route) is taken.
- agent/context_compressor.py: both sides added one import line; both kept.
- gateway/run_turn.py: main's 4c7ab8b2a0 added trigger="gateway_hygiene" to the hygiene
  _compress_context call this branch moved to gateway/run_turn_hygiene.py; the branch side
  of run_turn.py is kept and the trigger is carried onto the moved call.
2026-10-10 06:49:02 -07:00
mnajafian-nv
43fda4b388 fix(compression): report committed effects without leaking metric state
Finalize effect counts from the transcript that crosses the commit boundary, including retained partial-compression tails and boundary anchors. Explicitly discard bypassed shared-metric state so a later refusal cannot consume stale attempt metadata.

Signed-off-by: mnajafian-nv <mnajafian@nvidia.com>
(cherry picked from commit ddf3b229a9e2fdee651f36afbec974717d334f76)
2026-10-10 04:27:27 -07:00
mnajafian-nv
4c7ab8b2a0 fix(compression): name the automatic trigger and effect in attempt telemetry
The content-free attempt record is the one place that says why a
compaction ran and what it did, but it could not answer either question:

- Every automatic caller passed no trigger, so idle, turn-start
  threshold, engine preflight, pre-API, post-tool and gateway hygiene
  attempts all logged trigger_source=auto. Each call site now passes its
  own label; the shared metric still buckets them as auto.
- tokens after, message counts and how the summary was made were
  computed and logged as prose but never reached the record. A finished
  rewrite now records messages_before/after, tokens_before/after,
  tokens_reclaimed (signed; a summary can grow a short transcript),
  token_count_method=estimate_rough, method (llm_summary,
  aux_fallback_main, deterministic_fallback), items_dropped, and the
  tool_results_pruned / reasoning_items_pruned pass counts.
- Attempts that never reached the local compressor returned silently:
  the automatic breaker gate (before and under the lease), every Codex
  app-server exit, a lease that found the session already rotated, and
  an unreadable durable cooldown. Each now logs one record with a
  commit_status (blocked, skipped, failed, aborted, committed), a route,
  and a class such as blocked:cooldown. These stay out of shared metrics,
  which never counted them.

Test doubles for _compress_context gain the trigger keyword the call
sites now pass.

Signed-off-by: mnajafian-nv <mnajafian@nvidia.com>
(cherry picked from commit 1795993d1a01d91dd76e6ec824cb606f8a03b897)
2026-10-10 04:27:27 -07:00
Teknium
4e7fbad8fe Merge origin/main (#34: 43 commits to 3eb7ed08d1) into feat/unified-gateway-runtime
Two conflicts:
- tui_gateway/server.py: main's a274d3388f (#135781) quoted the two _TurnScopes
  annotations in code this branch already moved and quoted; the branch side is kept.
- website/docs/developer-guide/relay-shared-metrics.md: main added channel_unresolved's
  config note, gateway_pause_failed and the blobless-preflight sentence to the
  hermes.update.run failure-class row; the branch's downgrade_refused entry is spliced
  into main's row after commit_point_refused.
2026-10-09 18:41:50 -07:00
Teknium
5e46b9591f fix(update): say when the syntax preflight is skipped on a slow object fetch; sort gateway_pause_failed
The timed-out cat-file read is caught in target_syntax_error (the preflight) instead of
read_target_files, so the preflight prints one line saying the post-update check still runs;
publish_recovery_closure keeps suppressing the timeout as before.
2026-10-09 14:36:08 -07:00
Teknium
f549ce3fbd fix(update): drop config_unreadable: an unreadable config.yaml also hides consent, so no row is ever sent
The exit is real (RuntimeError from require_readable_config_before_write), but the consent gate
reads the same config.yaml and reads it as collection off: a live run on a scratch install with
an unparseable config.yaml wrote no metrics store at all. A closed value nothing can emit only
widens the contract.
2026-10-09 14:36:08 -07:00
Teknium
2379b2e2eb fix(update): pre-apply exits that read exception/subprocess_failed name their reason
hermes.update.run rows with apply_mode=unknown still had three exits with no stop_class on main:

- The startup-syntax preflight (update_cmd_commit.read_target_files) runs `git cat-file --batch`
  under a 120 s limit. On a blobless install (install.sh clones --filter=blob:none) every changed
  blob lazily fetches in its own round trip, so a slow link times out and the uncaught
  TimeoutExpired ended the whole update as `subprocess_failed` after 2+ minutes (31 CLI + 23
  Desktop install-days). An unread batch now counts as unread files, which is the preflight's
  documented contract; the post-move syntax check stays the backstop.
- An unreadable/unparseable config.yaml (require_readable_config_before_write RuntimeError) or an
  invalid configured channel name (ChannelError) while picking the channel read `exception`. They
  now record `config_unreadable` (new) / `channel_unresolved`.
- A failed Windows gateway pause (_abort_on_error / ServicePauseFailed RuntimeError) read
  `exception`; it now records `gateway_pause_failed` (new).

Two closed UPDATE_STOP_CLASSES values, the v4 schema enum and the relay-shared-metrics doc row
change together; every legacy value stays valid.
2026-10-09 14:36:08 -07:00
Teknium
408cc0d12e Merge origin/main (#32: 36 commits to cf23a1a5cc) into feat/unified-gateway-runtime
17 conflicts, all from main's lint sweep (ruff UP007/UP017/UP022/UP028/UP031/UP037/UP041,
FURB188/FURB192); no other main commit touches a conflicted file. Resolution: the branch side
of each file plus main's exact autofix (ruff 0.15.10, main's ruff.strict.toml, --fix
--unsafe-fixes). ruff.strict.toml takes main's copy. The pool-retirement live fixture stays
deleted with the pooled backend this branch retires.
2026-10-09 10:24:04 -07:00
Maciej Lisiewski
9eab688b42 ci: ruff UP017 fixes 2026-10-09 17:34:36 +02:00
Maciej Lisiewski
32b70e9733 ci: FURB188, FURB192 linter fixes 2026-10-09 17:31:52 +02:00
Teknium
1427a3a38c fix(update): refuse to move an install back past the gateway runtime once a state.db depends on it
jquesnelle item 6 asks that older code refuse a downgrade. Already-released code cannot be
changed, but this release's updater is the one that performs the move. `hermes update
--branch <old>`, a channel switch to an older release, and a pinned release commit all
pass through _refuse_before_commit_point before the tree changes.

update_downgrade_guard.downgrade_refusal refuses only when both of these hold:
  * the target does not descend from HEAD (forward updates never match) and none of its
    hermes_state*.py files defines the session_admissions ledger. This is one
    `git grep` against the object store, and the pathspec keeps a blobless clone from
    fetching the tree. Any git failure proves nothing and does not refuse;
  * the state.db of this profile or a sibling profile holds session_admissions or
    worker_executions rows. A read-only open; an unreadable store or one with no runtime
    tables does not refuse.

The refusal names each affected store and says downgrading is unsupported. It gives the
way back: `hermes gateway stop`, check out the older release, then put back each store's
pre-upgrade copy. It names the newest pre-update quick snapshot whose state.db predates
the ledger (`/snapshot restore <id>` on the older release). When no snapshot predates the
cutover it points at `hermes import <backup.zip>`. Nothing moves, and the receipt records
the closed stop token `downgrade_refused` (contract, v4 schema enum and metrics doc
updated together).

Verified against the real objects: with an r7-written store holding ledger rows, targets
v0.21.6 and origin/main are refused and HEAD passes.

Review: https://github.com/NousResearch/hermes-agent/pull/106742#issuecomment-6073624820
(cherry picked from commit 9688fff768cc595752b7f7bd9f4074274ef6b49f)
2026-10-09 02:10:49 -07:00
Teknium
71704ffb49 refactor: move Spotify out of core into the spotify catalog plugin
The spotify toolset (plugins/spotify) and its loopback-PKCE login (hermes_cli/auth_spotify.py)
now live in NousResearch/hermes-spotify, installed from the plugin catalog. Same pattern as the
Home Assistant move (fb9fc8a3dd): a LEFT_CORE row installs the plugin for every home that was
using it (a Spotify login in auth.json, or the spotify toolset in platform_toolsets) on
`hermes update` / first start; the toolset name, tool names, schemas, env vars and stored login
(providers.spotify) are unchanged, so nobody re-authenticates.

The one user-visible change is the login command: plugins cannot extend `hermes auth`, so the
plugin registers `hermes spotify login|status|logout`. LeftCoreFeature gains a `cli` field and
moved_command_hint() turns `hermes auth [status|logout] spotify`, and `hermes spotify` while the
plugin is not loaded, into a line naming the new command and the install/enable step for this
home. The dashboard's "needs login" hint names the new command too.

Core drops the Spotify auth constants/dispatch, the CONFIGURABLE_TOOLSETS row and post-setup
step, the core `spotify` entries in the shared-metrics toolset enums, its tests, and the docs
(en + zh-Hans) now point at `hermes plugins install spotify` / `hermes spotify login`.
2026-10-08 19:00:45 -07:00
alt-glitch
db02737cf3 Merge remote-tracking branch 'origin/main' into sid/onboarding 2026-10-07 20:37:24 +05:30