Skip to content

docs: document gateway client API contracts#89383

Closed
steipete wants to merge 72 commits into
mainfrom
codex/protocol-schema-comments-20260602
Closed

docs: document gateway client API contracts#89383
steipete wants to merge 72 commits into
mainfrom
codex/protocol-schema-comments-20260602

Conversation

@steipete

@steipete steipete commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Document gateway client reconnect-pause metadata, request-error wrapper, and close-code hint contracts.
  • Document timeout resolver behavior in both the reusable gateway-client package and OpenClaw runtime wrapper.
  • Document device-auth signing payload builders and the auth-vs-policy metadata normalization split.
  • Document MCP loopback protocol constants, JSON-RPC builders, safe tool-name reads, and tool-schema union flattening.
  • Document node pairing auto-approval reasons, client-IP source classification, and first-time-node-only CIDR policy.
  • Document gateway server utility contracts for voice-wake trigger normalization and compact error formatting.
  • Document gateway probe target resolution and remote-mode fallback reporting.
  • Document transcript-file to session-key lookup cache and ambiguity handling.
  • Document run-id to session-key lookup cache, agent-scope filtering, and miss-race behavior.
  • Document session-store key canonicalization, default-agent alias remapping, and lineage key handling.
  • Document process-local approval runtime token generation and timing-safe validation.
  • Document hook agent allowlist wildcard and unrestricted-routing policy.
  • Document explicit Gateway config-bypass policy for direct URL/auth calls and cron command paths.
  • Document public operator scope vocabulary and runtime scope allowlist invariants.
  • Document Gateway auth-token resolution precedence and env/config conflict diagnostics.
  • Document Gateway auth SecretRef materialization clone boundary and active-ref ordering.
  • Document shared HTTP response/body/SSE/disconnect helper contracts.
  • Document Gateway HTTP auth helper APIs and scope-resolution variants.
  • Document shared Gateway POST+JSON endpoint dispatch helper contract.
  • Document Gateway live-state and Control UI bootstrap contracts.
  • Document channel plugin reload target matching contracts.
  • Document Gateway cron failure/completion notification dispatch contracts.
  • Document Gateway model-catalog cache refresh and invalidation contracts.
  • Document channel status patch helpers and assistant stream text extraction.
  • Document channel health policy evaluation and restart-reason contracts.
  • Document Gateway connection detail resolution contracts.
  • Document Gateway config reload settings normalization.
  • Document Gateway model-pricing enablement default.
  • Document MCP loopback runtime publication and token-selection helpers.
  • Document Control UI CSP hash/header helpers.
  • Document Control UI HTTP method/response helpers.
  • Document Control UI link resolution for operator output.
  • Document Control UI routing and shared avatar/base-path helper contracts.
  • Document Gateway auth-mode ambiguity policy contracts.
  • Document Gateway install auth-token requirement policy contracts.
  • Document Gateway auth-token source conflict diagnostic contracts.
  • Document Gateway client bootstrap URL/auth provenance contracts.
  • Document Gateway chat envelope sanitizer contracts.
  • Document Gateway chat attachment parsing/offload contracts.
  • Document Gateway chat abort lifecycle contracts.
  • Document Gateway chat display projection and history sanitizer contracts.
  • Document Gateway direct child-session helper contracts.
  • Document Gateway session history snapshot and SSE state contracts.
  • Document Gateway session lifecycle projection and persistence contracts.
  • Document Gateway session transcript archive/path helper contracts.
  • Document Gateway compaction checkpoint helper contracts.
  • Document Gateway session resolver result and selector contracts.
  • Document Gateway session patch helper contract.
  • Document Gateway session reset lifecycle helper contracts.
  • Document Gateway session HTTP, patch-hook, and reactivation helper contracts.
  • Document Gateway session runtime tracker and transcript path helper contracts.
  • Document Gateway session utility row/default/store/model contracts.
  • Document Gateway transcript reader, usage, and preview helper contracts.
  • Document Gateway transcript index cache and active-tree contracts.
  • Document Gateway session method and Talk session mode/ownership contracts.
  • Document Gateway node/session event runtime fanout contracts.
  • Document Gateway session history/lifecycle state projection contracts.
  • Document Gateway node subscription, chat-run, subscriber, and Talk-node registry contracts.
  • Document Gateway node registry invoke/event authorization contracts.
  • Document Gateway node event dedupe/persistence, pending-action, Talk PTT, and invoke-result compatibility contracts.
  • Document Gateway request-context, embedded local context, and shared node-method error helper contracts.
  • Document Gateway node pending-work queue, drain, ack, and wake-staging contracts.
  • Document Gateway websocket auth fallback, locality, rate-limit, and signature-version helper contracts.
  • Document Gateway websocket auth failure-message, log-limiter, and unauthorized-flood contracts.
  • Document Gateway websocket shared-generation, preauth-budget, close-reason, and runtime adapter contracts.
  • Document Gateway websocket lazy handler loading, budget release, stale-node disconnect, and client registration contracts.
  • Document Gateway websocket shared-auth generation, trusted-proxy scope, and pairing recovery contracts.
  • Document Gateway server helper event-loop/readiness, hook dispatch/auth, plugin route auth, and plugin node-capability contracts.
  • Document Gateway plugin HTTP dispatch registry, route fallthrough, runtime-scope injection, and upgrade rejection contracts.
  • Document Gateway auth rate-limit, connection credential, and interactive/probe auth-surface resolution contracts while removing stale file-header commentary.
  • Document Gateway shared-secret, trusted-proxy, browser-origin, and Tailscale auth branch contracts.
  • Document Gateway HTTP pipeline probe redaction, plugin auth/dispatch context, stage routing, and liveness contracts.
  • Document Gateway exec approval lifecycle, id lookup, and system.run replay guard contracts.

Verification

  • git diff --check
  • pnpm test packages/gateway-client/src/client.watchdog.test.ts packages/gateway-client/src/timeouts.test.ts src/gateway/client.test.ts src/tui/gateway-chat.test.ts
  • pnpm test src/gateway/device-auth.test.ts src/gateway/node-command-policy.test.ts src/gateway/gateway-misc.test.ts
  • pnpm test src/gateway/mcp-http.test.ts src/gateway/gateway-cli-backend.live-probe-helpers.test.ts
  • pnpm test src/gateway/node-pairing-auto-approve.test.ts src/gateway/server.node-pairing-auto-approve.test.ts src/gateway/server.node-pairing-authz.test.ts
  • pnpm test src/gateway/gateway-misc.test.ts
  • pnpm test src/gateway/probe-auth.test.ts
  • pnpm test src/gateway/session-transcript-key.test.ts
  • pnpm test src/gateway/server-session-key.test.ts src/gateway/server-methods/artifacts.test.ts src/gateway/server-methods/sessions.abort-agent-scope.test.ts
  • pnpm test src/gateway/session-utils.test.ts
  • pnpm test src/gateway/operator-approvals-client.test.ts src/agents/tools/gateway.test.ts src/gateway/server/ws-connection/message-handler.post-connect-health.test.ts
  • pnpm test src/gateway/hooks.test.ts src/gateway/server.hooks.test.ts src/security/audit-hooks-routing.test.ts
  • pnpm test src/gateway/call.test.ts src/cli/command-path-policy.test.ts
  • pnpm test src/gateway/method-scopes.test.ts src/agents/tools/gateway.test.ts
  • pnpm test src/commands/doctor-gateway-auth-token.test.ts src/commands/status.scan.config-shared.test.ts src/security/audit-gateway.test.ts src/commands/doctor-security.test.ts
  • pnpm test src/gateway/startup-auth.test.ts src/pairing/setup-code.test.ts src/gateway/call.test.ts
  • pnpm test src/gateway/http-common.test.ts src/gateway/http-common.fuzz.test.ts
  • pnpm test src/gateway/http-utils.request-context.test.ts src/gateway/http-utils.authorize-request.test.ts src/gateway/http-endpoint-helpers.test.ts
  • pnpm test src/gateway/http-endpoint-helpers.test.ts src/gateway/openai-http.test.ts src/gateway/openresponses-http.test.ts src/gateway/embeddings-http.test.ts
  • pnpm test src/gateway/server-request-context.test.ts src/gateway/control-ui.http.test.ts
  • pnpm test src/gateway/plugin-channel-reload-targets.test.ts src/gateway/server-aux-handlers.test.ts
  • pnpm test src/gateway/server-cron-notifications.test.ts src/gateway/server.cron.test.ts
  • pnpm test src/gateway/server-model-catalog.test.ts
  • pnpm test src/gateway/channel-status-patches.test.ts src/gateway/openai-http.test.ts src/gateway/openresponses-http.test.ts
  • pnpm test src/gateway/channel-health-policy.test.ts src/gateway/channel-health-monitor.test.ts src/gateway/server.health.test.ts src/gateway/server-methods/channels.status.test.ts
  • pnpm test src/gateway/call.test.ts src/gateway/client-bootstrap.test.ts src/commands/status.scan.shared.test.ts src/cli/capability-cli.test.ts
  • pnpm test src/gateway/config-reload.test.ts src/gateway/server-methods/config.test.ts src/gateway/server-methods/config.shared-auth.test.ts
  • pnpm test src/gateway/model-pricing-cache.test.ts src/gateway/server-runtime-services.test.ts src/commands/health.test.ts
  • pnpm test src/gateway/mcp-http.test.ts src/gateway/gateway-cli-backend.live-probe-helpers.test.ts src/agents/cli-runner/prepare.test.ts
  • pnpm test src/gateway/control-ui-csp.test.ts src/gateway/control-ui.http.test.ts
  • pnpm test src/gateway/control-ui-routing.test.ts src/gateway/control-ui.http.test.ts
  • pnpm test src/commands/onboard-helpers.test.ts src/commands/dashboard.test.ts src/cli/daemon-cli/status.print.test.ts
  • pnpm test src/gateway/control-ui-routing.test.ts src/gateway/control-ui.http.test.ts src/commands/onboard-helpers.test.ts src/commands/status.scan.shared.test.ts
  • pnpm test src/gateway/auth-mode-policy.test.ts src/gateway/startup-auth.test.ts src/commands/gateway-install-token.test.ts
  • pnpm test src/commands/doctor-gateway-auth-token.test.ts src/commands/gateway-install-token.test.ts
  • pnpm test src/commands/status.scan.config-shared.test.ts src/commands/doctor-security.test.ts src/security/audit-gateway.test.ts
  • pnpm test src/gateway/client-bootstrap.test.ts src/gateway/call.test.ts src/gateway/operator-approvals-client.test.ts
  • pnpm test src/gateway/chat-sanitize.test.ts src/gateway/server-methods/chat.directive-tags.test.ts
  • pnpm test src/gateway/chat-attachments.test.ts src/gateway/server.agent.gateway-server-agent-a.test.ts
  • pnpm test src/gateway/chat-abort.test.ts src/gateway/server-methods/chat.abort-authorization.test.ts src/gateway/server-methods/models-auth-status.test.ts
  • pnpm test src/gateway/server-methods/server-methods.test.ts
  • pnpm test src/gateway/session-child-sessions.test.ts
  • pnpm test src/gateway/session-history-state.test.ts
  • pnpm test src/gateway/session-lifecycle-state.test.ts
  • pnpm test src/gateway/session-transcript-files.fs.archive-events.test.ts src/gateway/session-utils.fs.test.ts
  • pnpm test src/gateway/session-compaction-checkpoints.test.ts
  • pnpm test src/gateway/sessions-resolve.test.ts src/gateway/sessions-resolve-store.test.ts src/agents/tools/embedded-gateway-stub.test.ts
  • pnpm test src/gateway/sessions-patch.test.ts src/tui/embedded-backend.test.ts
  • pnpm test src/gateway/server.sessions.reset-hooks.test.ts src/gateway/drain-active-sessions-for-shutdown.test.ts src/gateway/server-close.test.ts src/channels/plugins/acp-stateful-target-driver.test.ts
  • pnpm test src/gateway/session-kill-http.test.ts src/gateway/sessions-history-http.revocation.test.ts src/gateway/session-subagent-reactivation.test.ts
  • pnpm test src/gateway/active-sessions-shutdown-tracker.test.ts src/gateway/drain-active-sessions-for-shutdown.test.ts src/gateway/server-methods/agent.create-event.test.ts src/gateway/sessions-history-http.revocation.test.ts
  • pnpm test src/gateway/session-utils.test.ts src/gateway/session-utils.plugin-runtime.test.ts src/gateway/session-utils.subagent.test.ts
  • pnpm test src/gateway/session-utils.fs.test.ts src/gateway/session-transcript-files.fs.archive-events.test.ts
  • pnpm test src/gateway/session-utils.fs.test.ts src/gateway/server-methods/chat.directive-tags.test.ts
  • pnpm test src/gateway/server.sessions.list-changed.test.ts src/gateway/server-methods/sessions.abort-agent-scope.test.ts src/gateway/server-methods/sessions.send-deleted-agent.test.ts src/gateway/server-methods/sessions.send-followup-status.test.ts src/gateway/server-methods/talk.test.ts
  • pnpm test src/gateway/gateway-misc.test.ts src/gateway/session-message-events.test.ts
  • pnpm test src/gateway/session-history-state.test.ts src/gateway/session-lifecycle-state.test.ts
  • pnpm test src/gateway/gateway-misc.test.ts src/gateway/server-talk-nodes.test.ts src/gateway/server-chat.agent-events.test.ts
  • pnpm test src/gateway/node-registry.test.ts src/gateway/server-node-events.test.ts src/gateway/server-methods/nodes.invoke-wake.test.ts
  • pnpm test src/gateway/server-node-events.test.ts src/gateway/server-methods/nodes-pending.test.ts src/gateway/server-methods/nodes.invoke-wake.test.ts src/gateway/gateway-misc.test.ts
  • pnpm test src/gateway/server-request-context.test.ts src/gateway/local-request-context.test.ts src/gateway/server-methods/nodes-pending.test.ts src/gateway/server-methods/push.test.ts src/gateway/server-methods/environments.test.ts
  • pnpm test src/gateway/node-pending-work.test.ts src/gateway/server-methods/nodes-pending.test.ts src/gateway/server-methods/nodes.invoke-wake.test.ts
  • pnpm test src/gateway/server/ws-connection/auth-context.test.ts src/gateway/server/ws-connection/auth-context.state.test.ts src/gateway/server/ws-connection/handshake-auth-helpers.test.ts
  • pnpm test src/gateway/server/ws-connection/auth-messages.test.ts src/gateway/server/ws-connection/unauthorized-flood-guard.test.ts src/gateway/server/ws-connection/handshake-auth-log-limiter.test.ts
  • pnpm test src/gateway/server/ws-shared-generation.test.ts src/gateway/server/preauth-connection-budget.test.ts src/gateway/server/ws-connection.test.ts
  • pnpm test src/gateway/server/ws-connection.test.ts src/gateway/server/ws-connection.startup.test.ts src/gateway/server/ws-connection/message-handler.post-connect-health.test.ts
  • pnpm test src/gateway/server/ws-connection.test.ts src/gateway/server/ws-connection.startup.test.ts src/gateway/server/ws-connection/message-handler.post-connect-health.test.ts src/gateway/server/ws-connection/auth-context.test.ts src/gateway/server/ws-connection/connect-policy.test.ts
  • pnpm test src/gateway/server-node-events.test.ts src/gateway/server-methods/nodes-pending.test.ts src/gateway/server-methods/nodes.invoke-wake.test.ts src/gateway/gateway-misc.test.ts
  • pnpm test src/gateway/server/event-loop-health.test.ts src/gateway/server/readiness.test.ts src/gateway/server/http-listen.test.ts src/gateway/server/hooks.agent-trust.test.ts src/gateway/server/plugin-route-runtime-scopes.test.ts src/gateway/server/plugins-http.runtime-scopes.test.ts src/gateway/server/plugins-http/route-capability.test.ts src/gateway/server/plugins-http.test.ts
  • pnpm test src/gateway/server/plugins-http.test.ts src/gateway/server/plugins-http.runtime-scopes.test.ts src/gateway/server/plugin-route-runtime-scopes.test.ts src/gateway/server/plugins-http/route-capability.test.ts
  • pnpm test src/gateway/auth-rate-limit.test.ts src/gateway/auth-surface-resolution.test.ts src/gateway/connection-auth.test.ts src/gateway/auth.test.ts
  • pnpm test src/gateway/auth.test.ts src/gateway/auth-rate-limit.test.ts src/gateway/origin-check.test.ts src/gateway/net.test.ts
  • pnpm test src/gateway/server-http.stages.test.ts src/gateway/server-http.probe.test.ts src/gateway/server-http.request-trace.test.ts src/gateway/server.plugin-http-auth.test.ts
  • pnpm test src/gateway/exec-approval-manager.test.ts src/gateway/node-invoke-system-run-approval.test.ts src/gateway/node-invoke-system-run-approval-match.test.ts src/gateway/system-run-approval-binding.test.ts src/gateway/system-run-approval-binding.contract.test.ts

Real behavior proof

Behavior addressed: exported gateway client API contracts are now documented for reconnect pause callbacks, request error handling, close-code hints, connect challenge timeout resolution, device-auth signing payloads, metadata normalization, MCP loopback JSON-RPC/tool-schema handling, node pairing auto-approval policy, voice-wake trigger normalization, gateway error formatting, probe target resolution, transcript-file session lookup, run-id session-key lookup, session-store key canonicalization, approval runtime token validation, hook agent allowlist routing, explicit Gateway config-bypass policy, operator scope vocabulary, Gateway auth-token precedence diagnostics, Gateway auth SecretRef materialization, shared HTTP helpers, HTTP auth helper APIs, the POST+JSON endpoint dispatch helper, Gateway live state, Control UI bootstrap payloads, channel plugin reload target matching, cron notification dispatch, model-catalog cache refresh/invalidation, channel status patches, assistant stream text extraction, channel health policy evaluation, Gateway connection detail resolution, Gateway config reload settings normalization, model-pricing enablement, MCP loopback runtime publication/token selection, Control UI CSP hashing/header construction, Control UI HTTP method/response helpers, Control UI link resolution, Control UI routing/shared avatar/base-path helper contracts, Gateway auth-mode ambiguity policy contracts, Gateway install auth-token requirement policy contracts, Gateway auth-token source conflict diagnostic contracts, Gateway client bootstrap URL/auth provenance contracts, Gateway chat envelope sanitizer contracts, Gateway chat attachment parsing/offload contracts, Gateway chat abort lifecycle contracts, Gateway chat display projection contracts, Gateway direct child-session helper contracts, Gateway session history snapshot/SSE state contracts, Gateway session lifecycle projection/persistence contracts, Gateway transcript archive/path helper contracts, Gateway compaction checkpoint helper contracts, Gateway session resolver selector contracts, Gateway session patch helper contract, Gateway session reset lifecycle helper contracts, Gateway session HTTP/reactivation helper contracts, Gateway session runtime tracker/path helper contracts, Gateway session utility row/default/store/model contracts, Gateway transcript reader/usage/preview helper contracts, Gateway transcript index cache/active-tree contracts, Gateway session method/Talk session mode and ownership contracts, Gateway node/session event runtime fanout contracts, Gateway session history/lifecycle state projection contracts, Gateway node subscription/chat-run/subscriber registry contracts, Gateway node registry invoke/event authorization contracts, Gateway server helper event-loop/readiness, hook dispatch/auth, plugin route auth, and plugin node-capability contracts, Gateway plugin HTTP dispatch registry, route fallthrough, runtime-scope injection, and upgrade rejection contracts, Gateway auth rate-limit/credential/surface resolution contracts, Gateway shared-secret/trusted-proxy/browser-origin/Tailscale auth branch contracts, Gateway HTTP pipeline probe redaction/plugin-stage/routing contracts, and Gateway exec approval lifecycle/replay guard contracts.
Real environment tested: local OpenClaw checkout on codex/protocol-schema-comments-20260602, rebased on origin/main.
Exact steps or command run after this patch: git diff --check; pnpm test packages/gateway-client/src/client.watchdog.test.ts packages/gateway-client/src/timeouts.test.ts src/gateway/client.test.ts src/tui/gateway-chat.test.ts; pnpm test src/gateway/device-auth.test.ts src/gateway/node-command-policy.test.ts src/gateway/gateway-misc.test.ts; pnpm test src/gateway/mcp-http.test.ts src/gateway/gateway-cli-backend.live-probe-helpers.test.ts; pnpm test src/gateway/node-pairing-auto-approve.test.ts src/gateway/server.node-pairing-auto-approve.test.ts src/gateway/server.node-pairing-authz.test.ts; pnpm test src/gateway/gateway-misc.test.ts; pnpm test src/gateway/probe-auth.test.ts; pnpm test src/gateway/session-transcript-key.test.ts; pnpm test src/gateway/server-session-key.test.ts src/gateway/server-methods/artifacts.test.ts src/gateway/server-methods/sessions.abort-agent-scope.test.ts; pnpm test src/gateway/session-utils.test.ts; pnpm test src/gateway/operator-approvals-client.test.ts src/agents/tools/gateway.test.ts src/gateway/server/ws-connection/message-handler.post-connect-health.test.ts; pnpm test src/gateway/hooks.test.ts src/gateway/server.hooks.test.ts src/security/audit-hooks-routing.test.ts; pnpm test src/gateway/call.test.ts src/cli/command-path-policy.test.ts; pnpm test src/gateway/method-scopes.test.ts src/agents/tools/gateway.test.ts; pnpm test src/commands/doctor-gateway-auth-token.test.ts src/commands/status.scan.config-shared.test.ts src/security/audit-gateway.test.ts src/commands/doctor-security.test.ts; pnpm test src/gateway/startup-auth.test.ts src/pairing/setup-code.test.ts src/gateway/call.test.ts; pnpm test src/gateway/http-common.test.ts src/gateway/http-common.fuzz.test.ts; pnpm test src/gateway/http-utils.request-context.test.ts src/gateway/http-utils.authorize-request.test.ts src/gateway/http-endpoint-helpers.test.ts; pnpm test src/gateway/http-endpoint-helpers.test.ts src/gateway/openai-http.test.ts src/gateway/openresponses-http.test.ts src/gateway/embeddings-http.test.ts; pnpm test src/gateway/server-request-context.test.ts src/gateway/control-ui.http.test.ts; pnpm test src/gateway/plugin-channel-reload-targets.test.ts src/gateway/server-aux-handlers.test.ts; pnpm test src/gateway/server-cron-notifications.test.ts src/gateway/server.cron.test.ts; pnpm test src/gateway/server-model-catalog.test.ts; pnpm test src/gateway/channel-status-patches.test.ts src/gateway/openai-http.test.ts src/gateway/openresponses-http.test.ts; pnpm test src/gateway/channel-health-policy.test.ts src/gateway/channel-health-monitor.test.ts src/gateway/server.health.test.ts src/gateway/server-methods/channels.status.test.ts; pnpm test src/gateway/call.test.ts src/gateway/client-bootstrap.test.ts src/commands/status.scan.shared.test.ts src/cli/capability-cli.test.ts; pnpm test src/gateway/config-reload.test.ts src/gateway/server-methods/config.test.ts src/gateway/server-methods/config.shared-auth.test.ts; pnpm test src/gateway/model-pricing-cache.test.ts src/gateway/server-runtime-services.test.ts src/commands/health.test.ts; pnpm test src/gateway/mcp-http.test.ts src/gateway/gateway-cli-backend.live-probe-helpers.test.ts src/agents/cli-runner/prepare.test.ts; pnpm test src/gateway/control-ui-csp.test.ts src/gateway/control-ui.http.test.ts; pnpm test src/gateway/control-ui-routing.test.ts src/gateway/control-ui.http.test.ts; pnpm test src/commands/onboard-helpers.test.ts src/commands/dashboard.test.ts src/cli/daemon-cli/status.print.test.ts; pnpm test src/gateway/control-ui-routing.test.ts src/gateway/control-ui.http.test.ts src/commands/onboard-helpers.test.ts src/commands/status.scan.shared.test.ts; pnpm test src/gateway/auth-mode-policy.test.ts src/gateway/startup-auth.test.ts src/commands/gateway-install-token.test.ts; pnpm test src/commands/doctor-gateway-auth-token.test.ts src/commands/gateway-install-token.test.ts; pnpm test src/commands/status.scan.config-shared.test.ts src/commands/doctor-security.test.ts src/security/audit-gateway.test.ts; pnpm test src/gateway/client-bootstrap.test.ts src/gateway/call.test.ts src/gateway/operator-approvals-client.test.ts; pnpm test src/gateway/chat-sanitize.test.ts src/gateway/server-methods/chat.directive-tags.test.ts; pnpm test src/gateway/chat-attachments.test.ts src/gateway/server.agent.gateway-server-agent-a.test.ts; pnpm test src/gateway/chat-abort.test.ts src/gateway/server-methods/chat.abort-authorization.test.ts src/gateway/server-methods/models-auth-status.test.ts; pnpm test src/gateway/server-methods/server-methods.test.ts; pnpm test src/gateway/session-child-sessions.test.ts; pnpm test src/gateway/session-history-state.test.ts; pnpm test src/gateway/session-lifecycle-state.test.ts; pnpm test src/gateway/session-transcript-files.fs.archive-events.test.ts src/gateway/session-utils.fs.test.ts; pnpm test src/gateway/session-compaction-checkpoints.test.ts; pnpm test src/gateway/sessions-resolve.test.ts src/gateway/sessions-resolve-store.test.ts src/agents/tools/embedded-gateway-stub.test.ts; pnpm test src/gateway/sessions-patch.test.ts src/tui/embedded-backend.test.ts; pnpm test src/gateway/server.sessions.reset-hooks.test.ts src/gateway/drain-active-sessions-for-shutdown.test.ts src/gateway/server-close.test.ts src/channels/plugins/acp-stateful-target-driver.test.ts; pnpm test src/gateway/session-kill-http.test.ts src/gateway/sessions-history-http.revocation.test.ts src/gateway/session-subagent-reactivation.test.ts; pnpm test src/gateway/active-sessions-shutdown-tracker.test.ts src/gateway/drain-active-sessions-for-shutdown.test.ts src/gateway/server-methods/agent.create-event.test.ts src/gateway/sessions-history-http.revocation.test.ts; pnpm test src/gateway/session-utils.test.ts src/gateway/session-utils.plugin-runtime.test.ts src/gateway/session-utils.subagent.test.ts; pnpm test src/gateway/session-utils.fs.test.ts src/gateway/session-transcript-files.fs.archive-events.test.ts; pnpm test src/gateway/session-utils.fs.test.ts src/gateway/server-methods/chat.directive-tags.test.ts; pnpm test src/gateway/server.sessions.list-changed.test.ts src/gateway/server-methods/sessions.abort-agent-scope.test.ts src/gateway/server-methods/sessions.send-deleted-agent.test.ts src/gateway/server-methods/sessions.send-followup-status.test.ts src/gateway/server-methods/talk.test.ts; pnpm test src/gateway/gateway-misc.test.ts src/gateway/session-message-events.test.ts; pnpm test src/gateway/session-history-state.test.ts src/gateway/session-lifecycle-state.test.ts; pnpm test src/gateway/gateway-misc.test.ts src/gateway/server-talk-nodes.test.ts src/gateway/server-chat.agent-events.test.ts; pnpm test src/gateway/node-registry.test.ts src/gateway/server-node-events.test.ts src/gateway/server-methods/nodes.invoke-wake.test.ts.
Evidence after fix: focused package/client, core wrapper, TUI gateway-chat, device-auth, node-command policy, gateway misc, MCP loopback HTTP, MCP live-probe helper, node pairing auto-approve/authz, probe auth, session transcript-key, server-session-key, artifacts, session abort-agent-scope, session-utils, operator approvals client, gateway tool, websocket post-connect health, hooks, server hooks, audit hooks routing, gateway call, CLI command-path, method-scope, doctor token, status scan config, audit gateway, doctor security, startup auth, pairing setup-code, HTTP common, HTTP request-context, HTTP authorize-request, HTTP endpoint helper, OpenAI HTTP, OpenResponses HTTP, embeddings HTTP, server request-context, Control UI HTTP, plugin channel reload-target, server aux-handler, cron notification, gateway cron, model-catalog, channel status/HTTP stream, channel health policy, connection details, client bootstrap, status scan, capability CLI, config reload, config write/shared-auth, model-pricing cache, runtime services, health, MCP HTTP, MCP live-probe helper, CLI prepare, Control UI CSP, Control UI routing, Control UI HTTP, onboard helper, dashboard, daemon status, auth-mode policy, startup auth, doctor gateway-token, gateway install-token, status scan config, doctor security, audit gateway, client bootstrap, gateway call, operator approvals client, chat sanitizer, chat directive-tag, chat attachments, gateway agent attachment, chat abort, chat abort authorization, model auth-status, server-methods display projection, session child helper, session history state, session lifecycle state, transcript archive events, session fs, compaction checkpoint, session resolver, embedded gateway stub, session patch, TUI embedded backend, reset-hook, shutdown-drain, server-close, ACP stateful target driver, session kill HTTP, session history revocation, subagent reactivation, active session shutdown tracker, session active-run projection, transcript path matching, session utility, plugin-runtime row, subagent session utility, transcript reader, transcript archive, usage, preview, transcript index, directive-tag reader, sessions list/change, session abort/send, Talk handler, gateway misc, session message-event, session history/lifecycle state, Talk-node, server chat agent-event, node-registry, server node-event, and node invoke/wake tests passed after the branch was rebased on current origin/main.
Observed result after fix: API comments are present on the shared package and core wrapper without adding file-header or import-area comments; device-auth metadata comments describe the reusable signing and policy contracts; MCP comments describe protocol negotiation and schema projection contracts; node pairing comments document the narrow auto-approval policy; server utility comments document bounded trigger normalization and diagnostic formatting; probe target comments document remote-mode fallback semantics; transcript lookup comments document cache reset and ambiguous-session handling; run-session lookup comments document miss caching and agent-scope filtering; session-store comments document persisted-key canonicalization and legacy default-agent alias handling; approval runtime comments document token generation and timing-safe validation; hook policy comments document wildcard/unrestricted routing semantics; explicit connection policy comments document when config loading and config guard bypasses are intentional; operator-scope comments document public scope meanings and the runtime allowlist invariant; auth-token comments document precedence and when env fallback/conflict warnings are intentional; auth-config comments document local materialization of active SecretRefs without mutating canonical config; HTTP helper comments document shared response, body-limit, SSE, and disconnect semantics; HTTP auth comments document reusable header parsing, auth metadata, scoped authorization, and shared-secret scope resolver variants; endpoint helper comments document path-delegation and auth-before-body ordering; live-state comments document startup-assembled runtime state and Control UI bootstrap contracts; reload-target comments document channel/plugin alias matching and exact/subpath config detection; cron notification comments document failure/completion dispatch contracts and non-blocking completion webhooks; model-catalog comments document cache invalidation and stale refresh publishing semantics; channel status and assistant stream comments document liveness patch semantics and delta-over-snapshot extraction; channel health comments document policy/result contracts and inherited transport timestamp handling; connection details comments document the resolved target/explanation shape and resolver-injected builder contract; reload-settings comments document normalized reload mode/debounce semantics; model-pricing config comments document default-enabled optional pricing refresh behavior; MCP loopback runtime comments document active runtime snapshots, owner/non-owner token selection, owner-token guarded cleanup, and env-placeholder server config; Control UI CSP comments document inline-script hash handling, attribute parsing, and restrictive header construction; Control UI HTTP comments document read-method routing and shared plain-text/not-found response helpers; Control UI link comments document operator-facing HTTP/WebSocket URL resolution across bind modes; auth-mode policy comments document the dual-credential ambiguity guard and SecretRef ownership invariant; install auth-policy comments document explicit mode decisions and durable service-env password inference; token-source conflict comments document shared audit/status fields and warning suppression invariants; client-bootstrap comments document URL provenance mapping and explicit override auth precedence; chat sanitizer comments document envelope stripping and sender-label attribution preservation; chat attachment comments document raw attachment, inline image, offloaded media-ref, parser, preflight, and legacy builder contracts; chat abort comments document stop matching, run expiry, registration, tracked adapters, provider metadata, and abort fanout contracts; chat display projection comments document history text limits, tool block detection, display sanitization, recent-message projection, and single-message projection contracts; child-session comments document direct lineage matching and non-recursive listing contracts; session-history comments document tail-window sizing, display-safe snapshots, SSE page state, inline append refresh behavior, and disk refresh contracts; lifecycle comments document event-to-row projection, persisted patch normalization, and reset-rotated row protection; transcript archive comments document candidate ordering, archive event emission, source-to-archive mapping, stable end-transcript selection, and archive cleanup counts; compaction checkpoint comments document retained-byte limits, reason mapping, tail leaf scans, checkpoint forks/capture/persist, cleanup, and lookup/list contracts; session resolver comments document the canonical key/error union and key/sessionId/label selector resolution contract; session patch comments document validated sessions.patch mutation without direct store writes; session reset comments document archive helper variants, start/end/unbind hook emission, cleanup-before-mutation, global-store agent inference, ACP reset metadata migration, and replacement transcript creation before lifecycle hooks; session HTTP comments document kill path handling, requester-vs-admin kill scopes, history path/limit handling, SSE auth rechecks, patch-hook cloning, and lazy completed-subagent reactivation; session runtime comments document shutdown finalization tracker APIs, global-session active-run agent matching, and transcript path comparison for not-yet-created files; session utility comments document public row/result types, canonical/legacy store lookup, default thinking/model resolution, image capability checks, and normalized Gateway session row construction; transcript reader comments document OpenClaw metadata attachment, full/recent/indexed reads, count caching, message id lookup, recent sequence annotations, usage snapshots, capped arrays, title extraction, and preview item construction; transcript index comments document visible indexed entries, cache clearing, oversized-line placeholders, active tree-chain selection, and shared in-flight index builds; session method comments document parent runtime inheritance, global-agent notifications, WebChat mutation blocking, checkpoint branch/restore selection, transcript creation, abort alias resolution, scoped abort ownership, send/steer delegation, preview store caching, main-DM reset semantics, child creation hooks, and Talk mode/transport/brain ownership checks; session event comments document node/session registry wiring, node delivery adapters, Talk presence snapshots, global message subscription fanout, session snapshot goal redaction, serialized transcript broadcasts, sequence fallback reads, display-safe message broadcasts, and sessions.changed fallback events; session state comments document exact cursor parsing, raw-tail pagination, duplicate live append refreshes, message-tool mirror seq attachment, hidden control-message refreshes, terminal outcome status mapping, lifecycle timestamp preference, and runtime preservation for partial lifecycle events; subscription comments document bidirectional node/session indexes, single-serialization fanout, node-level bypass broadcasts, chat-run FIFO ownership, run buffer cleanup, websocket subscriber reverse cleanup, tool-event recipient TTLs, and Talk-node capability detection; node-registry comments document serialized payload branding, reconnect-safe unregister, declared-surface narrowing, system.run authorization, legacy macOS fallback ambiguity, failed-invoke cleanup, raw event JSON embedding, and slow-consumer closure.
Latest slice proof: commit 896def0 documents approval record publication, resolved-entry grace, one-shot consumption, prefix lookup ambiguity, backend chat replay binding, approved-plan rehydration, and allow-once replay protection on current origin/main.
What was not tested: no full suite or live gateway session; this is documentation-only code commentary.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS maintainer Maintainer-authored PR size: S and removed size: XS labels Jun 2, 2026
@steipete
steipete force-pushed the codex/protocol-schema-comments-20260602 branch from a3dce23 to 020a659 Compare June 2, 2026 08:23
@clawsweeper

clawsweeper Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 29, 2026, 7:55 PM ET / 23:55 UTC.

Summary
The branch adds JSDoc and invariant comments documenting Gateway client, auth, websocket, HTTP, Control UI helper, MCP, session, plugin HTTP, and related Gateway helper contracts.

Reproducibility: not applicable. this is a source-comment documentation PR rather than a bug report or runtime behavior change. The relevant checks are contract accuracy, branch mergeability, owner approval, and the contributor's after-patch validation evidence.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: unknown-data-model-change: src/gateway/session-compaction-checkpoints.ts, unknown-data-model-change: src/gateway/session-history-state.ts, unknown-data-model-change: src/gateway/session-lifecycle-state.ts, unknown-data-model-change: src/gateway/session-reset-service.ts, unknown-data-model-change: src/gateway/session-store-key.ts, unknown-data-model-change: src/gateway/session-transcript-files.fs.ts, and 5 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Refresh the branch from an account that can push the source branch.
  • Get Gateway and security-aware maintainer approval for the broad contract wording, or split the sweep into narrower owner surfaces.

Risk before merge

  • [P1] Live GitHub reports the branch as dirty/conflicting and not rebaseable, with maintainer_can_modify=false, so someone with source-branch access must refresh it before merge.
  • [P1] The PR turns many Gateway auth, session, websocket, client, and plugin HTTP internals into source-level contract language; if maintainers do not want those behaviors to guide future compatibility decisions, the wording should be narrowed or split before merge.

Maintainer options:

  1. Refresh and review Gateway contracts (recommended)
    Have someone with branch access resolve the dirty/conflicting branch, then route the broad auth/session/websocket/client/plugin HTTP comments through Gateway-aware maintainer review.
  2. Accept the contract language intentionally
    Maintainers may decide the documented internals should become source-level compatibility guidance after the branch is refreshed.
  3. Split by owner surface
    If the sweep is too broad to approve at once, pause or close this PR and replace it with narrower area-specific comment PRs.

Next step before merge

  • The remaining action is protected-label maintainer handling: refresh the dirty branch and decide whether the broad Gateway contract comments should land as written.

Security
Cleared: No concrete security or supply-chain regression was found because the diff changes source comments and helper placement only, without workflows, lockfiles, dependency manifests, scripts, permissions, secrets, or auth logic changes.

Review details

Best possible solution:

Refresh the branch, then have Gateway and security-aware maintainers approve, narrow, or split the source-contract comments before merge.

Do we have a high-confidence way to reproduce the issue?

Not applicable; this is a source-comment documentation PR rather than a bug report or runtime behavior change. The relevant checks are contract accuracy, branch mergeability, owner approval, and the contributor's after-patch validation evidence.

Is this the best way to solve the issue?

No, not merge-ready as-is: source comments are an appropriate place for non-obvious Gateway invariants under AGENTS.md, but the breadth of compatibility wording and the dirty branch need Gateway-aware maintainer handling first.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 18b2ff683fd3.

Label changes

Label justifications:

  • P3: This is low-priority source documentation/commentary work with no claimed runtime behavior change.
  • merge-risk: 🚨 compatibility: The diff codifies many Gateway internals as source-level contract comments that can shape future compatibility and upgrade decisions.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes after-patch local checkout proof with git diff --check, extensive targeted Gateway tests, and observed success for the documented source-comment sweep.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-patch local checkout proof with git diff --check, extensive targeted Gateway tests, and observed success for the documented source-comment sweep.
Evidence reviewed

What I checked:

  • Repository policy read and applied: Root policy requires full AGENTS.md plus scoped guides before review, treats Gateway/auth/session compatibility as merge-sensitive, and explicitly allows inline comments for non-obvious invariants when they preserve reviewer context. (AGENTS.md:29, 18b2ff683fd3)
  • Scoped Gateway guide checked: The touched Gateway subtree has a scoped guide focused on Gateway hot paths, static plugin descriptors, and Gateway test discipline; no scoped rule made the comment-only diff automatically closeable. (src/gateway/AGENTS.md:1, 18b2ff683fd3)
  • Live PR state blocks cleanup close and merge: GitHub reports the PR open at head 896def0 with mergeable=CONFLICTING, REST mergeable_state=dirty, rebaseable=false, maintainer_can_modify=false, and labels including maintainer, proof: sufficient, P3, and merge-risk: 🚨 compatibility. (896def06ad3a)
  • Diff surface is source-comment documentation across Gateway internals: The PR file list spans 113 source files under packages/gateway-client/src and src/gateway; sampled patches add comments/JSDoc and one helper relocation without introducing a runtime feature, dependency, workflow, or lockfile change. (packages/gateway-client/src/client.ts:360, 896def06ad3a)
  • Current Gateway client contracts exist on main: Current main exposes GatewayReconnectPausedInfo, GatewayClientRequestError, close-code hints, and the connect-challenge timeout resolver that the PR documents in both the reusable package and runtime wrapper. (packages/gateway-client/src/client.ts:360, 18b2ff683fd3)
  • Representative auth/session/plugin behavior matches the documented surfaces: Current main includes the trusted-proxy auth branches, missing-credential rate-limit behavior, protected plugin route path canonicalization, session-store key canonicalization, and shared Gateway session-generation hashing that representative PR comments describe. (src/gateway/auth.ts:305, 18b2ff683fd3)

Likely related people:

  • steipete: History over sampled touched files is dominated by Peter Steinberger, including session-store and plugin HTTP registry work that overlaps this PR's documented surfaces; he is also the source author with prior merged area history, not merely this PR's opener. (role: recent Gateway area contributor; confidence: high; commits: 5f3356a746ba, a69f6190ab56, 198c2482eeb2; files: src/gateway/session-store-key.ts, src/gateway/server/plugins-http.ts, src/gateway/session-utils.ts)
  • vincentkoc: Recent history shows Vincent Koc hardening trusted-proxy origin checks and narrowing plugin route runtime scopes, both central classes of contract comments in this PR. (role: recent Gateway auth and plugin-scope contributor; confidence: high; commits: 6b3f99a11f4d, 2a1db0c0f1fa; files: src/gateway/auth.ts, src/gateway/server/plugin-route-runtime-scopes.ts, src/gateway/server/plugins-http.ts)
  • Takhoffman: Recent history shows repeated work on freshest duplicate session rows, store matches, and related session state surfaces that this PR documents across Gateway session helpers. (role: session-state area contributor; confidence: medium; commits: c37e49f275fb, 24dd7aec90c0, f48571bec6f2; files: src/gateway/session-store-key.ts, src/gateway/session-utils.ts, src/gateway/session-history-state.ts)
  • pgondhi987: History shows shared-token/password websocket session invalidation work in the same Gateway auth/session-generation area that this PR turns into source contract comments. (role: adjacent auth/session security contributor; confidence: medium; commits: 5880ec17b18c; files: src/gateway/server/ws-shared-generation.ts, src/gateway/auth.ts)
  • Nick Taylor: Symbol history for authorizeTrustedProxy points to Nick Taylor introducing the trusted-proxy auth mode, which is one of the security-sensitive auth contracts documented by this PR. (role: feature introducer; confidence: medium; commits: 1fb52b4d7bce; files: src/gateway/auth.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-06-21T09:16:41.179Z sha 896def0 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/protocol-schema-comments-20260602 branch 3 times, most recently from 7e2d8a0 to 0430f0a Compare June 2, 2026 08:43
@steipete
steipete requested a review from a team as a code owner June 2, 2026 08:43
@steipete
steipete force-pushed the codex/protocol-schema-comments-20260602 branch 4 times, most recently from f4a63e8 to a2474b9 Compare June 2, 2026 09:10
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 2, 2026
@steipete
steipete force-pushed the codex/protocol-schema-comments-20260602 branch from 87f06c8 to 84e54dd Compare June 2, 2026 09:23
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M and removed size: S labels Jun 2, 2026
@steipete
steipete force-pushed the codex/protocol-schema-comments-20260602 branch 8 times, most recently from 29a52ba to de6f18a Compare June 2, 2026 10:30
@steipete
steipete force-pushed the codex/protocol-schema-comments-20260602 branch from c0e8d66 to 30348b6 Compare June 2, 2026 11:24
@clawsweeper clawsweeper Bot added the P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. label Jun 2, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jun 15, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jun 19, 2026
@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Closing this broad source-comment sweep. It changes 113 fast-moving Gateway files and is conflicting; even with strong test proof, reviewing this many maintainer-facing contract claims as one unit is not reliable or worth the compatibility burden. The maintainable alternative is a narrow current-main PR for one Gateway contract at a time, reviewed with its callers, tests, and owner boundary. A new focused PR would be welcome with that scope and proof.

@steipete steipete closed this Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant