Skip to content

fix(gateway): reconnect hibernated read-only sessions - #158

Open
jmwhite310 wants to merge 3 commits into
ScriptedAlchemy:mainfrom
jmwhite310:fix/hibernated-read-reconnect
Open

jmwhite310 wants to merge 3 commits into
ScriptedAlchemy:mainfrom
jmwhite310:fix/hibernated-read-reconnect

Conversation

@jmwhite310

Copy link
Copy Markdown

Summary

Recover allowlisted read-only gateway calls when a cached desktop route points to a hibernated pod. A locally decryptable descriptor does not establish that its remote computer is reachable.

The observed failure was HTTP 417 with x-anyrun-error-source: anyrun-proxy, x-anyrun-failure-reason: pod_hibernated, and proxy error destination_unavailable.

Relationship to existing work

This branch builds on open PR #154 and includes its descriptor-v3 compatibility and Windows regression commits, preserving Nicolas Mertens's and Lee SiHyeon's original authorship. The new reconnect commit is e76b5a0.

Related: #143, #145, #147, #149, #152. Active-account credential loading and app-version handling follow the desktop storage structure documented in #152. This adds recovery when a descriptor is present but points to a hibernated pod, rather than only when the descriptor is absent.

Behavior and safety boundaries

  • Load only the explicitly active desktop account, through existing Safe Storage / Windows DPAPI helpers; validate the selected team and installed app version.
  • Bind reconnect to the account selected when the session was established; reject account changes before or during refresh.
  • Call the existing allowlisted EnsureSandBox backend to obtain a fresh gateway URL, bearer credential, and routing headers.
  • Coalesce concurrent refreshes per session and retry an affected read only once.
  • Reconnect only for the exact AnyRun hibernation response, and only for listAgents, getAgentWorkflows, getAgentTranscriptTail, and getAgentThread.
  • Never automatically replay mutations, sends, or approval actions. Generic HTTP errors, network failures, explicit gateway overrides, and unbound externally supplied sessions do not trigger desktop-account fallback.
  • Preserve credential destination policy, redirect rejection, and cancellation checks.
  • Keep refreshed routing state in memory. Do not overwrite desktop-owned descriptor/secrets files or export plaintext credentials.
  • Include a patch changeset and rebuilt CLI/MCP/relay artifacts.

Validation

Passed on Windows with Node 24.13.0 and Grok Bot Desktop 0.71.2:

  • 67 gateway/session regression tests, including the new reconnect, concurrency, account-drift, credential-policy, failure-redaction, cancellation, Windows credential, and no-write-replay cases.
  • 97 route tests across 5 test files.
  • Typechecking and source validation.
  • Build and generated-artifact validation with --no-host-validation.
  • git diff --check.

External Claude host validation is not claimed: the default build stopped with AB6022 from the installed Claude developer validator. The supported --no-host-validation option was used for build/artifact verification. A prior broader targeted run also exposed a CRLF/LF frontmatter assertion in codex-commands.test.js; the full cross-platform suite is not claimed green.

Live read-only acceptance

  • Cached listAgents returned 417 / pod_hibernated.
  • Exactly one EnsureSandBox request returned 200 using the installed app version.
  • Retried listAgents returned 200 on a changed route.
  • A second read using the refreshed session also returned 200.
  • A separate invocation of the rebuilt dist/bin/gbot.mjs bots list --gateway --json succeeded.
  • The desktop-owned descriptor hash remained unchanged.

No Bot messages or mutations were sent during live verification. Credentials, account identifiers, roster contents, and conversation content are excluded from this report.

Development artifacts

Co-Authored-By: Warp agent@warp.dev

Nicolas Mertens and others added 3 commits October 16, 2026 12:54
Current Grok Bot desktop builds write gateway-descriptor.json version 3,
which keeps the version 2 entries layout (adds savedAtMs per entry).
Every command failed with "Unsupported Grok Bot gateway descriptor
version 3". Treat v3 like v2; the multiple-entries safety check stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F7jcCQRFPBA9cNGeLvEoJi
Exercise the existing Windows DPAPI key-provider path with synthetic v3
fixtures, including invalid entries and AES-GCM authentication failure.
Run the built doctor command for v2 and v3 under isolated app-data paths
on Windows as well as macOS/Linux, covering the flight worker bundle.

Refresh the artifact source snapshot while preserving its executable mode.
Load active desktop credentials through Safe Storage, detect the installed client version, and coalesce a single account-bound refresh for explicit AnyRun hibernation responses. Retry only allowlisted reads; preserve explicit routing overrides and never replay mutations.

Add reconnect/security regressions and rebuild distribution artifacts. Verified 67 gateway/session tests, 97 route tests, typecheck, and live read-only connectivity.

Co-Authored-By: Warp <agent@warp.dev>
@changeset-bot

changeset-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e76b5a0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
grok-bot-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant