Skip to content

fix: harden gateway status and Photon sidecar startup - #53868

Open
nomadjames wants to merge 7 commits into
NousResearch:mainfrom
nomadjames:boddicker-gateway-status-photon-upstream-20260627
Open

fix: harden gateway status and Photon sidecar startup#53868
nomadjames wants to merge 7 commits into
NousResearch:mainfrom
nomadjames:boddicker-gateway-status-photon-upstream-20260627

Conversation

@nomadjames

Copy link
Copy Markdown

Summary

  • Preserve the Claude handoff memory endpoint on the API server.
  • Add safer gateway long-turn notices and turn-usage reporting.
  • Preserve explicit zero budget settings in gateway usage handling.
  • Tighten profile gateway/status detection, including systemd profile services, bare-list cron stores, and host-vs-container detection.
  • Keep the Photon sidecar alive if the optional Spectrum mixed-attachment compatibility patch fails, so basic iMessage transport is not taken down by patch/package-layout drift.

Test plan

  • node --check plugins/platforms/photon/sidecar/index.mjs
  • node --check plugins/platforms/photon/sidecar/patch-spectrum-mixed-attachments.mjs
  • ./venv/bin/python -m py_compile gateway/platforms/api_server.py gateway/run.py gateway/long_run_status.py gateway/turn_usage.py gateway/slash_commands.py hermes_cli/config.py hermes_cli/gateway.py hermes_cli/status.py hermes_constants.py plugins/platforms/photon/adapter.py
  • ./venv/bin/python -m pytest -q tests/gateway/test_api_server.py tests/gateway/test_api_server_claude_handoff.py tests/gateway/test_gateway_long_running_notifications.py tests/gateway/test_long_run_status_enrichment.py tests/gateway/test_turn_usage.py tests/gateway/test_usage_command.py tests/hermes_cli/test_gateway.py tests/hermes_cli/test_gateway_service.py tests/hermes_cli/test_status_redaction.py tests/plugins/platforms/photon/test_mention_gating.py tests/plugins/platforms/photon/test_spectrum_patch.py tests/test_hermes_constants.py -o 'addopts='

Local result: 513 passed, 112 warnings.

James Dishman added 7 commits June 27, 2026 19:34
(cherry picked from commit faf3cc18c5dbffce680f2dd7154d3adaab980b7d)
(cherry picked from commit dce0a5614ef46f93c9d3d258626584cff42599c2)
(cherry picked from commit 59d9854c833a10af672cf3779498dd80722a7420)
(cherry picked from commit 23c20642cb5477b28e34c15c8ff2a1e19daeeadc)
(cherry picked from commit 5b5d3f0d5097aaf162e7854f4fb9be2523eba6f5)
(cherry picked from commit 541738da54f2673cf2e0e076059fc025c80775e6)
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery comp/cli CLI entry point, hermes_cli/, setup wizard comp/plugins Plugin system and bundled plugins sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages P2 Medium — degraded but workaround exists labels Jun 27, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Observation: High surface area (22 files, +1711/-44)

This PR introduces a new 365-line module (gateway/long_run_status.py) for optional gateway status enrichment, plus changes to gateway/run.py for noisy status filtering and a new handle_busy_turn_choice method.

Positive observations:

  • The enrichment module is deliberately fail-soft (docstring is clear)
  • Status line validation regex looks correct
  • The _GATEWAY_NOISY_STATUS_RE expansion to cover more platforms is a good improvement
  • The handle_busy_turn_choice method is well-structured with clear branching

Areas for human review:

  • 22 files is above the surface-area threshold for automated confidence
  • The new long_run_status.py module integrates with external services (Ollama, OpenRouter) — worth verifying the error handling covers all failure modes
  • The busy-turn choice feature touches gateway run.py core — confirm no prompt-caching impact

Recommend human review before merge due to surface area.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing several real gateway and Photon failure modes. The Photon premise is confirmed on current main: plugins/platforms/photon/sidecar/index.mjs:225-233 still exits the sidecar when the optional compatibility patch fails.

Problems

  • gateway/platforms/api_server.py:1292-1297 advertises a handoff API but imports clarence_db by injecting ~/.openclaw/workspace/scripts into global sys.path. The repository has no clarence_db implementation or declared dependency, and tests/gateway/test_api_server_claude_handoff.py:61-74 succeeds only by injecting a fake module. A standard installation would return the endpoint's 500 path.
  • gateway/long_run_status.py:318 records the daily OpenRouter call before urlopen() succeeds (:320-323), so transient failures consume the quota.

Suggested changes

  • Put the handoff write behind a declared, configured Hermes memory-provider surface and advertise/register it only when available; avoid request-time global sys.path mutation.
  • Record cloud usage only after a successful response, with a failed-request quota regression test.

Current main also still waits 180 seconds before the first long-turn notice (gateway/run.py:19336-19342), so the core notification and Photon fixes remain worth salvaging. This is an automated hermes-sweeper review.

import sys as _sys
if str(workspace_scripts) not in _sys.path:
_sys.path.insert(0, str(workspace_scripts))
from clarence_db import ClarenceDB # type: ignore

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This advertised endpoint depends on an undeclared deployment-local module loaded by mutating global sys.path; the repository contains no clarence_db package or dependency, while the test injects a fake module. Please use a declared/configured Hermes memory-provider integration and gate the capability/route when it is unavailable.

},
method="POST",
)
_record_cloud_call()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This increments the daily quota before urlopen() succeeds, so timeouts and transport failures consume the allowance. Record the call only after a successful response is accepted, and add a failed-request regression test.

@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins P2 Medium — degraded but workaround exists sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants