From 97b29915370decd9b5ce8f5b24d7ecb60b1140fb Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sun, 20 Sep 2026 18:01:07 +0530 Subject: [PATCH] refactor(gateway): publish/write forward **fields to the shared preparer The 18-keyword signature was copy-pasted onto write_runtime_status and publish_runtime_status and forwarded one by one. Keep the explicit keyword-only signature on _prepare_runtime_status_update (typo safety at the boundary) and let the two public wrappers forward **fields. No positional callers exist (all call sites use keywords). --- gateway/status.py | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/gateway/status.py b/gateway/status.py index 610a9851cd..32fe6fa2e8 100644 --- a/gateway/status.py +++ b/gateway/status.py @@ -1044,31 +1044,17 @@ def _emit_runtime_status_transition( def write_runtime_status( - *, gateway_state: Any = _UNSET, exit_reason: Any = _UNSET, restart_requested: Any = _UNSET, - active_agents: Any = _UNSET, active_work: Any = _UNSET, platform: Any = _UNSET, platform_state: Any = _UNSET, - error_code: Any = _UNSET, error_message: Any = _UNSET, needs_attention: Any = _UNSET, - retrying_since: Any = _UNSET, served_profiles: Any = _UNSET, session_store: Any = _UNSET, - multiplex_standalone_reason: Any = _UNSET, - ingress_url: Any = _UNSET, listener_base: Any = _UNSET, clear_profile_platforms: bool = False, - drop_profile_platforms: Optional[str] = None, reload_existing: bool = False, - wait_timeout: Optional[float] = None, + *, reload_existing: bool = False, wait_timeout: Optional[float] = None, **fields: Any, ) -> bool: """Synchronously persist status for CLI callers and off-loop startup. ``wait_timeout`` bounds how long the caller waits for durable persistence. A timed-out update remains queued for the single background writer. + Keyword ``fields`` are those of ``_prepare_runtime_status_update``. """ with _runtime_status_state_lock: path, payload, previous_payload = _prepare_runtime_status_update( - gateway_state=gateway_state, exit_reason=exit_reason, - restart_requested=restart_requested, active_agents=active_agents, active_work=active_work, - platform=platform, platform_state=platform_state, error_code=error_code, - error_message=error_message, needs_attention=needs_attention, - retrying_since=retrying_since, served_profiles=served_profiles, - session_store=session_store, multiplex_standalone_reason=multiplex_standalone_reason, - ingress_url=ingress_url, listener_base=listener_base, - clear_profile_platforms=clear_profile_platforms, drop_profile_platforms=drop_profile_platforms, - reload_existing=reload_existing) + reload_existing=reload_existing, **fields) writer = _get_runtime_status_writer() generation = writer.submit(path, payload) # Report the transition once it is queued (matching ``publish_runtime_status``): a @@ -1077,27 +1063,14 @@ def write_runtime_status( return writer.wait(generation, timeout=wait_timeout) -def publish_runtime_status( - *, gateway_state: Any = _UNSET, exit_reason: Any = _UNSET, restart_requested: Any = _UNSET, - active_agents: Any = _UNSET, active_work: Any = _UNSET, platform: Any = _UNSET, platform_state: Any = _UNSET, - error_code: Any = _UNSET, error_message: Any = _UNSET, needs_attention: Any = _UNSET, - retrying_since: Any = _UNSET, served_profiles: Any = _UNSET, session_store: Any = _UNSET, - multiplex_standalone_reason: Any = _UNSET, - ingress_url: Any = _UNSET, listener_base: Any = _UNSET, clear_profile_platforms: bool = False, - drop_profile_platforms: Optional[str] = None, -) -> int: - """Merge and enqueue status without waiting for filesystem persistence.""" +def publish_runtime_status(**fields: Any) -> int: + """Merge and enqueue status without waiting for filesystem persistence. + + Keyword ``fields`` are those of ``_prepare_runtime_status_update``. + """ with _runtime_status_state_lock: path, payload, previous_payload = _prepare_runtime_status_update( - gateway_state=gateway_state, exit_reason=exit_reason, - restart_requested=restart_requested, active_agents=active_agents, active_work=active_work, - platform=platform, platform_state=platform_state, error_code=error_code, - error_message=error_message, needs_attention=needs_attention, - retrying_since=retrying_since, served_profiles=served_profiles, - session_store=session_store, multiplex_standalone_reason=multiplex_standalone_reason, - ingress_url=ingress_url, listener_base=listener_base, - clear_profile_platforms=clear_profile_platforms, drop_profile_platforms=drop_profile_platforms, - load_existing=False) + load_existing=False, **fields) generation = _get_runtime_status_writer().submit(path, payload) _emit_runtime_status_transition(previous_payload, payload) return generation