Skip to content

fix(gateway): record Tailscale Control UI sources without a paired browser key - #204388

Merged
obviyus merged 1 commit into
mainfrom
fix/replay-wake-admission
Nov 24, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/replay-wake-admission

Conversation

@obviyus

@obviyus obviyus commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A durable exec (background) completion that ends after a Gateway restart wakes its chat as a session-principal system turn. For a person who uses the Control UI through Tailscale Serve on a Gateway without named roles, that wake was refused with Session principal has no current run authority.. The completion never reached the chat (exec: completion delivery failed). A new message from the same person in the same chat was admitted.

Root cause

  • A session-principal turn after a restart has no live socket. It is admitted only through the person's recorded source (session-operator-sources.ts: recordSessionOperatorSource on each chat.send, restoreSessionOperatorSource on the wake). If no source was recorded and the profile has no role, readScopes refuses.
  • Tailscale Serve skips Control UI pairing (connect-policy.ts: shouldSkipControlUiPairing → "tailscale-device"). So a desktop browser presents a device key that is never paired.
  • captureGatewayOperatorRecoverySnapshot looks up that key in the pairing store for tokenless proxy/Tailscale sources. If it found no row, it returned unavailableReason: "device-no-token". So every message from such a browser had no recovery snapshot, and the session never recorded a source.
  • Evidence from the incident Gateway (read-only): 180 of 180 recorded sources are tailscale with no device. The affected chat (used only from a desktop browser) had no operatorSources at all, after 12 prompts.

The brief's hypothesis (an OpenClaw ID linked-owner device, isLinkedOwnerDevice) is disproved: OpenClaw ID is disabled on that Gateway. The person connects with Tailscale identity auth.

Change

Delete the sourceDevice && tokenlessIdentity && !device refusal (production −3). A tokenless Tailscale/proxy source whose key has no pairing row is recorded like a device-less Tailscale source, as #202513 already specified: "Device-less proxy/Tailscale scopes use the current grant." Restore checks the auth method, identity grant and browser origin against the current config, the same checks a new connection gets. A paired key is still recorded and still re-checked (revoke/remove → refused). A pairing-store read failure still yields no snapshot.

No new flag, token, stored field or guard.

What the user sees

A durable exec that finishes after a Gateway restart now posts its completion turn to a Tailscale Control UI chat, as it did before the restart. A person with no recorded source and no role is still refused (unchanged; admits an untiered person's session work only through their recorded, current source).

Accepted edge case

A trusted-proxy Control UI key removed from pairing between connect and the first chat.send admission records a device-less source. Removing a device invalidates its live sockets, and admission checks client.invalidated, so this needs a race inside one request.

Why not Tailscale-only

A tokenless trusted-proxy key has no pairing row at capture only when (a) its connection skipped pairing (skipLocalBackendSelfPairing), so its live admission did not depend on pairing either, or (b) the device was removed after connect. Removal invalidates its sockets (invalidateClientsForDevice → readGatewayDeviceSourceAuthority), so admission refuses before capture. In both cases a device-less record admits the wake exactly when a new message would be admitted. Limiting the change to Tailscale would need a new authMethod guard, so I did not add one.

Tests

  • New, red on base, green on head: session-operator-sources.test.ts › "admits a restart wake for a Tailscale Control UI person whose browser key was never paired". It admits a new message through prepareGatewayOperatorRunAuthority, records it with recordSessionOperatorSource, then admits the wake with prepareSessionPrincipalRunAuthority({ sessionPrincipal: true }). Base fails at the wake with Session principal has no current run authority.; disabling Tailscale auth still refuses the wake.
  • bash-process-durable-notify.test.ts: unchanged. It covers only target preparation (prepareAdoptedDurableProcessNotification), which never reaches admission, so changing its principal could not catch this.

Evidence

  • Red on base, green on head: the new test (see Tests).
  • Pre-push, one ocx test call, 12 files (touched + importers of the changed source + test-support importers): 410 tests passed. Typecheck core + core tests, oxfmt and oxlint pass. check:changed: only the dead-export scan fails, on ui/src/pages/chat/components/chat-read-aloud-status.tsx (not in this diff).
  • E2E one-admission-e2e/run.sh on head 780f7d648c7e: Q (queued input refused visibly), R (running turn finishes), S (Stop cancels) all pass. The verdict.json and results.jsonl are attached below.
  • Gap: a scratch-Gateway Tailscale reproduction needs Tailscale Serve to proxy to it, which would change the host's live Serve route. The red-on-base test drives the real admission path instead: new-message admission → record → session-principal wake.

Follow-up (not in this PR)

The exec outcome should be written to the session history before the wake, so a refused or failed wake cannot lose it. This needs more than the admission fix; it belongs to the owed-result slice (W4, #204265).

…owser key

Tailscale Serve skips Control UI pairing, so a browser presents a device key
that is never paired. Capture refused a durable source for it, the session
never recorded the person's source, and a restart wake (durable exec
completion) for that chat was refused with "Session principal has no current
run authority." A new message from the same person was admitted.

An unpaired key is not part of that grant: record it like a device-less
Tailscale source, which restore checks against the current identity grant.

Co-authored-by: obviyus <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Nov 24, 2026
@obviyus

obviyus commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

E2E evidence, head 780f7d648c7e (one-admission-e2e/run.sh): Q/R/S pass.

verdict.json
{
  "pass": true,
  "prefix": "HEAD",
  "sessionKey": "agent:main:one-admission-c53ba0c1",
  "models": [
    "gpt-5.5-2026-04-23",
    null
  ],
  "relayStatuses": [
    200,
    421
  ],
  "checks": [
    {
      "id": "R.running-turn-finishes",
      "pass": true,
      "detail": {
        "state": "final",
        "toolEnds": 3,
        "toolEndsAfterRevoke": 3
      }
    },
    {
      "id": "Q.queued-input-refused-visibly",
      "pass": true,
      "detail": {
        "accepted": true,
        "providerRequestsWithQueuedMarker": 0,
        "visibleRefusalInTranscript": true
      }
    },
    {
      "id": "S.stop-cancels",
      "pass": true,
      "detail": {
        "abort": {
          "ok": true,
          "aborted": true,
          "runIds": [
            "b5bfbe72-52d5-4880-ba39-24abb31c8d83"
          ]
        },
        "state": "aborted",
        "requestsWithStopMarker": 1
      }
    }
  ],
  "elapsedMs": 61266
}```
</details>

results.jsonl: 28 lines, kept with the private run receipts.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 24, 2026
@obviyus

obviyus commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: the only red on head 780f7d648c7e is MAIN-ALSO.

  • check-lint-core-3 (run 45327200081, job 138221467017): src/config/sessions/session-transcript-reconcile.close-failure.test-support.mjs:3:38: error: Avoid referencing unbound methods ... (typescript(unbound-method)). This PR does not touch that file. The same error fails the same job on main 22a57c95b6 (run 45326636554, job 138218070686).
  • ci-triage 204388 output: # PR #204388 head 780f7d648c7e; main run 45319833099. It lists no failing test files: the red is a lint job, not a test job.

This PR changes only src/gateway/operator-run-recovery-source.ts (−3) and src/gateway/session-operator-sources.test.ts. Local oxlint on both files reports 0 warnings and 0 errors.

  • openclaw/ci-gate: aggregate gate; red only because check-lint-core-3 is red.

@obviyus
obviyus merged commit efaeb85 into main Nov 24, 2026
131 of 134 checks passed
@obviyus
obviyus deleted the fix/replay-wake-admission branch November 24, 2026 04:51
@obviyus

obviyus commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as efaeb85. Bug: a durable exec completion after a Gateway restart was refused for Tailscale Control UI chats, because an unpaired browser key blocked recording the person's source. Fix: record such sources like device-less Tailscale sources (production -3). Proof: a test that is red on base and green on head, E2E Q/R/S pass, local review clean; the only red was MAIN-ALSO check-lint-core-3 (override above).

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 25, 2026
…owser key (openclaw#204388)

Tailscale Serve skips Control UI pairing, so a desktop browser presents a device key that is never paired. Recovery-source capture refused a durable source for that key. The session never recorded the person's source, and after a Gateway restart a durable exec completion wake was refused with "Session principal has no current run authority." A new message from the same person was admitted.

The fix deletes the unpaired-key refusal (production -3). Such a source is recorded like a device-less Tailscale source, and restore checks it against the current identity grant. Paired keys are still re-checked.

Proof: a test that is red on base and green on head (new message admission -> record -> session-principal wake); the one-admission E2E passes Q/R/S on the head; local review is clean.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…owser key (#204388)

Tailscale Serve skips Control UI pairing, so a desktop browser presents a device key that is never paired. Recovery-source capture refused a durable source for that key. The session never recorded the person's source, and after a Gateway restart a durable exec completion wake was refused with "Session principal has no current run authority." A new message from the same person was admitted.

The fix deletes the unpaired-key refusal (production -3). Such a source is recorded like a device-less Tailscale source, and restore checks it against the current identity grant. Paired keys are still re-checked.

Proof: a test that is red on base and green on head (new message admission -> record -> session-principal wake); the one-admission E2E passes Q/R/S on the head; local review is clean.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit efaeb85)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant