fix(photon): persist sidecar runtime record so cron/standalone sends work - #73564
Merged
Conversation
Contributor
૮ >ﻌ< ა ci reviewran on 1b5de78 all good! |
…work The sidecar auth token is generated at spawn (secrets.token_hex) and existed only in the gateway process memory + sidecar child env, so _standalone_send from cron subprocesses, hermes send, or the dashboard structurally could not authenticate (#69960). The adapter now writes <hermes-home>/runtime/photon-sidecar.json ({port, token, pid}, 0600, atomic tempfile+os.replace) once the sidecar passes its /healthz readiness check, and deletes it in _stop_sidecar, on every startup-failure path, and at disconnect so a stale record never outlives a dead sidecar. _standalone_send falls back to the record when PHOTON_SIDECAR_TOKEN is unset, validating the recorded pid is alive first; a stale record yields a clear 'gateway appears to be down' error. Docs note the gateway-must-be-running requirement and the Photon-side shared-line initiation policy (#51897).
'photon:any;-;+1555...' targets matched no parser pattern, so _handle_send bounced them off the channel directory and failed resolution even though the adapter accepts the GUID verbatim (the react handler already passed them through). Recognize the DM chat GUID shape (mirrors the adapter's _DM_CHAT_GUID_RE) in _parse_target_ref for photon only.
teknium1
force-pushed
the
photon/cron-standalone-send
branch
from
July 28, 2026 20:33
6ee1bed to
1b5de78
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cron jobs and
hermes sendcan now deliver to Photon without the gateway process's in-memory state: the adapter persists a{port, token, pid}runtime record (0600, atomic) after the sidecar passes/healthz, and_standalone_sendfalls back to it whenPHOTON_SIDECAR_TOKENisn't in the env — previously standalone sends structurally could not succeed because the token only ever existed in gateway memory.Changes
plugins/platforms/photon/adapter.py:_write/_read/_delete_runtime_recordhelpers (profile-safe viaget_hermes_home(), atomic mkstemp+replace, Windows-guarded chmod); record written after healthz 200; deleted in_stop_sidecar, connect early-return, readiness-timeout, and died-before-ready paths;_standalone_sendvalidates recorded pid liveness (viagateway.status._pid_exists) before use, clean "gateway appears to be down" error on stale records.tools/send_message_tool.py:photon:any;-;+phonetarget-resolution fix (the issue's secondary bug).website/docs/user-guide/messaging/photon.md, plugin README): standalone/cron sends need the gateway running; shared/free-tier lines cannot initiate conversations with new targets (Photon-side policy — Photon: shared/free-tier lines cannot send outbound cron deliveries (Target not allowed) #51897).Validation
Fixes #69960.
Infographic