← Back to Pull requests

feat: upgrade legacy managed Gateways to Tailscale auth #1128

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Aug 08, 2026 08:38 UTC
Author

<!--
Optional linked context:
Add a visible Closes #<issue-number> or Related: #<issue-number> line
below this comment.

Required PR title:
type: user-facing description
Use a parenthesized scope only when it adds clarity:
fix(auth): login redirect loops when session cookie is expired

Types: feat, fix, improve, refactor, docs, chore.
For fixes, describe the user-visible symptom and trigger:
fix: task list fails to load when user has no environments
Avoid implementation details such as:
fix: add null check to task query

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
-->

Related: #1117. Separate from #1989. Maintainer proof requirements.

What Problem This Solves

<!--
Describe the concrete user, product, or operational problem.
Use one short, plain-language sentence. For fixes, prefer:
"Fixes: <what goes wrong> when <trigger or condition>."
For other changes, describe the need without inventing a bug.
Name the affected workflow, not the code-level cause.
-->

Existing Companion-managed WSL Gateways lack a supported in-place action to adopt Tailscale Dashboard authentication while preserving existing shared access.

User Impact

<!--
"User impact: <what users, operators, or developers can now do or expect>."
Lead with the concrete outcome in plain language, usually one sentence.
For internal-only changes, say there is no user-visible change; do not invent a benefit.
Keep important risks, breaking changes, migrations, and required user actions visible here.
-->

Operators can explicitly enable Core-verified Tailscale Dashboard authentication for eligible legacy managed Gateways. Existing credentials remain intact. This action supports Gateway-managed foreground Serve; it does not convert Setup background-Serve deployments or perform automatic migration. Real lab opt-in, local-persistence failure/retry and fixture-backed selective revocation are demonstrated below. Previous-version upgrade, complete proof-pool qualification and maintainer acceptance remain open.

Why This Change Was Made

<!--
Briefly explain how the change addresses the problem without repeating the impact.
Keep the body short. Leave file lists, internal acronyms, and root-cause walkthroughs
in the diff or optional <details>; include technical detail only when it explains
behavior or a material tradeoff. Do not hide risks or required actions in <details>.
-->

The upgrade captures the authenticated connection epoch before reading config, requires the existing admin scope and authoritative base hash, then patches only gateway.auth.allowTailscale. Replacement connections cannot receive a patch captured for the old connection. Core patch acceptance permits saving local trust; it does not prove asynchronous apply or continued ingress readiness. Dashboard link creation revalidates current config/applied state and managed ingress before a token-free launch.

Saved links validate the credential/export requirements for that link, and setup authority is checked immediately before browser dispatch after asynchronous validation. An independently approved browser credential remains an intentional fallback for this upgrade flow. Personal-mode no-fallback selection is the separate #1989 contract.

Evidence

<!--
Show the most useful proof that this change works. Screenshots, screencasts,
terminal output, focused tests, CI results, live observations, redacted logs,
and artifact links are all useful. Include before/after evidence for visual
changes when it clarifies the result.

Reviewers will inspect the code, tests, and CI. Use this section to make the
validation easy to understand, not to restate the diff.
Summarize what was checked and the result; note meaningful gaps. Link long output
or put it in optional <details>, keeping the useful evidence summary visible.
-->

Real Windows/WSL/browser qualification was collected on 14 November 2026. It now includes normal native opt-in from false/false, token-free authenticated browser access, accepted-config/local-save failure followed by retry, selective application-grant denial, retirement of an admitted browser with code 4001, denied reconnect, and independent valid authentication. Details and limitations are below.

Current source and the native proof binary are both ae660ef0e692d5dacb7a642cc026bd534560d8df, integrating frozen main 34e8b609. All three runtime scenarios were repeated on this exact head. Current-head Build and Test and CodeQL passed; complete proof-pool acceptance remains open. No merge readiness is claimed.

Change Type

  • Bug fix

  • Feature

  • Refactor

  • Docs or instructions

  • Tests or validation

  • Security hardening

  • Chore or infrastructure
  • Scope

  • Tray or WinUI UX

  • Windows node capability

  • Local MCP or winnode

  • Gateway, connection, or pairing

  • Setup or onboarding

  • Permissions, privacy, or security

  • Tests, CI, or docs
  • Required proof pools

    <!--
    Select every applicable pool ID from docs/PROOF_POOLS.md using:

  • <pool-id>: <reason>
  • Use none with a reason only when no capacity-dependent custom Windows proof is
    required. Declaring a pool schedules proof; it does not claim the proof ran.
    -->

  • windows-wsl-gateway-e2e: Partially qualified in operation. The three requested lab scenarios have real Gateway/browser evidence below. The grant policy is fixture-backed. A previous-version installer/data upgrade and the complete pool are not claimed.

  • windows-winui-interactive: Partially qualified in operation. Mounted native Connection menu opt-in, failure/retry and normal Dashboard browser dispatch ran. Remaining full UI/distribution obligations and current CI are separate.
  • Validation

    <!--
    Include exact commands and pass/fail counts. Baseline after code changes:

  • ./build.ps1

  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore

  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore
  • Add focused tests when relevant. In fresh worktrees, confirm tests actually ran
    and report non-zero test counts.
    For inventory-bound proof, link the local execution summary described in
    docs/PROOF_POOLS.md. A valid summary is not complete pool, visual, or binary-provenance proof.
    -->

  • ./build.ps1 -Project All -Configuration Debug -NoTrustRepository: all five targets passed on native Windows x64, source ae660ef0.

  • dotnet test tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj --no-restore --filter 'FullyQualifiedName~GatewayTailscaleAuthLiveVerifierTests|FullyQualifiedName~GatewayTailscaleAuthUpgradeTests': 156 passed, zero failures/skips. The new healthy-slow-probe regression failed before repair, then passed after it.

  • ./scripts/validate-test-timing-patterns.ps1: passed after marking the intentional latency with the repository's required timing directive. No baseline increase.

  • dotnet test tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore --filter FullyQualifiedName~TestDeterminismGuardTests: 38 passed, zero failures/skips after that directive.

  • Both increments received normal Codex Autoreview (scoped-clean P0–P3), TestAudit and named NoComments. Independent Astra reviewed the native timeout repair and fixture proof plan. The retained comment is machine-consumed timing metadata.

  • On current integration ae660ef0, 235 focused Connection cases, all 6,712 Tray cases and 557 focused approval/client cases passed. Full Shared had 5,871 passes, 30 skips and 12 explicit missing-symbolic-link-privilege failures; those failures were not hidden. Scoped Autoreview, NoComments and independent Astra reviewed the manual conflict resolution.

  • Current-head hosted Build and Test and CodeQL completed successfully. Earlier all-green runs remain historical.
  • Real Behavior Proof

    <!--
    Paste at least one current-head proof item that directly demonstrates the
    changed behavior. Use copied live output, screenshots or video, UI diagnostics,
    winnode output, raw MCP JSON-RPC, gateway invoke output, redacted runtime
    logs, or linked artifacts.
    -->

    Published and freshly built source: ae660ef0e692d5dacb7a642cc026bd534560d8df, integrating pinned main 34e8b6099f4cbf225c4247fa814e4823dd75c9d2. Native executable SHA-256: 102D56749223CFA6CA19B5365198C5AC34919A21A62610801A743BF457DF8A33. Native opt-in, failure/retry, normal browser dispatch, protected access/reload and selective revocation were repeated with this binary. Earlier results for 7676549c/2eb34396 remain historical records.

    Environment: Windows x64 Companion, a separate task-owned Ubuntu WSL Gateway running official OpenClaw 2026.11.3 (847611d), Tailscale 1.104.7, and genuine Gateway-owned foreground Serve on HTTPS 443. The saved legacy record and device were synthetic; the running Gateway, pairing, configuration transaction and browser were real. This is not a previous-version installer/upgrade proof. No model-provider credentials or private conversations were copied.

    | Scenario | Actual observed result |
    |---|---|
    | Existing record, client trust false and Core allowTailscale=false | Clean browser reached the Gateway but required a matching secret. Normal native Connection menu opt-in then received Core acceptance, persisted local trust and retained the original record/device. |
    | Token-free Dashboard | Generated HTTPS URL had no token query/fragment. A clean browser connected with hello.auth.method=tailscale and successfully requested agents.list. The normal mounted Connection Dashboard button, with external-browser suppression disabled, also opened a new default-Chrome tab which authenticated through Tailscale and successfully requested agents.list. Reload retained authenticated access. |
    | Accepted patch, failed local persistence | A temporary read-sharing lock on the synthetic registry prevented atomic persistence. UI reported that local trust could not be saved. Authoritative Core readback was true while persisted client trust was false. No rollback was claimed. After releasing the lock, the old device reconnected Ready and the normal retry persisted trust in the same record. No permission changes were used. |
    | Selective person denial and live revocation | A task-only plugin used Core's supported Gateway access-policy API. Its admin-scoped fixture method persisted revocation and aborted real captured grant signals; it did not close sockets or synthesize authorization failures. Core closed the admitted browser with code 4001. A subsequent protected request failed because that connection was retired, and fresh handshakes were denied at auth_validated with cause operator-access-denied. Serve remained reachable and independent pre-existing synthetic token/device authentication successfully fetched Gateway health over the same real WSS endpoint. |
    | Fixture mutation authority | A real shipped Core client admitted with only operator.read received FORBIDDEN: missing scope: operator.admin when invoking the fixture's revoke method. Repeating an authorized revocation reported zero newly aborted leases. |
    | Restoration | Restoring only the test grant with a new lifetime permitted a fresh Tailscale-authenticated browser connection and protected agents.list again. |

    The grant policy and its admin operation are explicitly fixture-backed. They demonstrate enforcement by real Core, not a native grant-management UI or an external grant store's notification delivery. Network ACL withdrawal, device-token deletion and global allowTailscale=false were not substituted for selective person revocation. A disconnected page can retain previously rendered content; that is not evidence of newly authorized protected I/O.

    Validation and remaining limits

  • Native full five-target build passed on ae660ef0.

  • The deliberate slow-probe regression failed before the fix (Ready expected, Unavailable returned after the old five-second aggregate deadline). After repair, 156 verifier/upgrade cases passed. The production runner's existing per-command timeout and cleanup remain in force; explicit verifier deadlines and caller cancellation remain supported.

  • Timing-pattern validation and all 38 determinism-guard tests passed after the required timing directive. No ratchet baseline was raised. Autoreview and named NoComments completed for both increments; NoComments retained the machine-consumed directive.

  • On the frozen integration, 235 focused Connection cases, all 6,712 Tray cases, and 557 focused approval/client integration cases passed. The manual test conflict resolution received scoped Autoreview, NoComments and independent Astra compatibility review.

  • Current-head Build and Test and CodeQL completed successfully. Previous-head green runs remain historical.

  • Local full Shared qualification had 5,871 passes, 30 skips and 12 failures caused by absent Windows symbolic-link privilege. Those failures were not hidden or relabelled green. Current hosted Shared/Core results must be read separately.

  • A previous-version installed-app upgrade, signing/distribution qualification and complete UI proof-pool coverage are not claimed. The local native viewport fixture was blocked at the required 1,000-DIP layout on this display; assertions and display settings were preserved.

  • Local private receipts contain endpoint/profile/device details and are not public artifact links. This summary intentionally omits those details. Maintainer acceptance and merge remain separate.
  • Security Impact

  • New permissions or capabilities? No new Core provider or operator grant; adds an explicit admin-gated configuration action.

  • Secrets or tokens handling changed? Yes: credential-free links require verified Tailscale readiness; independent browser credentials retain their export authorization.

  • New or changed network calls? Yes: config read/patch and existing managed Serve readiness checks.

  • Command or tool execution surface changed? Existing managed WSL/Serve diagnostics are used; no new end-user permission is granted.

  • Data access scope changed? No broader grant is intended; Core remains the authority.

  • If any answer is Yes, explain the risk and mitigation: captured connection epoch/base hash, explicit admin requirement, leaf-only patch, revalidation before identity readiness, retained credentials and final setup dispatch authority. Real lab denial and migration evidence is recorded above; full qualification and maintainer acceptance remain mandatory before merge.
  • Compatibility and Migration

  • Backward compatible? The real lab kept the original saved record, device identity and independent credential through opt-in and retry. Its legacy record was seeded through the production registry API; a previous-version installer/data upgrade is not claimed.

  • Config or environment changes? Explicit operator opt-in sets gateway.auth.allowTailscale=true only on the supported managed foreground-Serve topology. No automatic credential deletion or record replacement.

  • Migration needed? Operator-initiated adoption. Core acceptance and local persistence are separate; link creation still verifies applied config and current ingress before omitting a token.

  • Upgrade steps and residual limits: use the Connection menu's opt-in, retain independent access, and use its normal retry after correcting a local persistence failure. The demonstrated interruption was an accepted patch followed by failed local persistence, not an arbitrary power-loss proof. Full pool/distribution acceptance remains open.
  • Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.

  • I left unresolved only conversations that still need maintainer judgment.
  • The current evidence materially advances the requested migration/retry/selective-denial proof. Current-head Build and Test and CodeQL passed. Maintainer acceptance and full pool/distribution obligations remain open. No upstream merge or review-thread resolution is claimed.

    Current rebase proof (6eabf15c)

    Rebased onto upstream main 3670fcd6. The updated WinUI launcher compiles and the full repository build passed on Windows x64. The rebase preserves upstream typed request outcomes and the bound on time spent queued for dispatch. The connection and wizard request suites passed 156 and 16 focused tests on parent 60e97867. The final commit changes only a WinUI lambda parameter name. It resolves the sole P0–P3 review finding, and the independent review of that fix returned no further findings.

    The isolated full-app fixture passed the Dashboard hand-off and retry after a simulated browser failure at this head. The Retry dialog was visible in the capture and the test observed a successful retry for the same route. The earlier live upgrade, selective revocation and independent-authentication proofs above belong to their recorded revisions. A live upgrade rehearsal at the new head remains outstanding.

    CI cancellation follow-up (f58ffc04)

    The first rebased head reproduced SearchSessions_CallerCancellationWhileQueuedDoesNotWriteAfterUnlock in the hosted Core and soak jobs. Caller cancellation could unwind and dispose the dispatch deadline before its linked cancellation reached the queued send. The follow-up explicitly cancels that deadline before unwinding.

    The corrected head passed 19 focused search-cancellation and wizard-request cases. The exact previously failing test also passed in 12 independent test processes. The follow-up P0–P3 review returned no actionable findings. Earlier WinUI fixture evidence above remains bound to 6eabf15c.

    Additional validation at f58ffc04

    GitHub Core and CLI, changed-test soak, and the WSL network-recovery E2E jobs passed. The UI shard timed out reopening the Systems Gateway row at 1000 px. The exact test passed locally at both 1000 and 480 px on the same head. The hosted timeout remains visible in the UI job.

    The full native Windows build, Tray suite (7,131 tests), and WinNode CLI suite passed locally. The Shared suite hit 12 symlink-privilege failures. The three Connection failures and the three SetupEngine gateway-timeout formatting failures were reproduced in targeted tests on the pinned upstream baseline.

    The full mounted SystemsPageProofTests class also produced the same eight failed cases on this PR and on upstream main at 3670fcd6. The specific 1000 px Gateway row case that timed out on the hosted runner passed locally on both revisions.

    Current-head Windows Companion fixture

    On f58ffc04599497cb5ff6c3092825f1f6f1138384, four native app cases passed with a synthetic Gateway. The saved Channels receipt opened the Dashboard, rejected a revoked identity before launch, and remained available for successful retry after a browser failure. The separate Channels navigation case also exercised browser failure and retry. The full-app fixture used isolated Windows state.

    The latest-stable installed-state upgrade still needs a restorable Windows host and a real existing WSL Gateway. Check that the existing Gateway record, stored credentials and device pairing survive the upgrade, then run the agreed adoption, interruption/retry and denial cases. The hosted Systems-row timeout remains open.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: RomneyDa Review duration: 165526m
    All Vouch review confidence checks passed
    Residual risk 0.48 = Change Risk (0.82) × (1 − Review Confidence (0.42)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.82 · 650 lines diff across 8 files
    0.82
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.082
    Real PR Conversation Timeline
    1 comments
    "Review active on #1128"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 42.2% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 82.2% (HIGH) · Higher = larger blast radius
    82.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 42.2% · Lower = rushed or shallow review
    42.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 47.5% · Moderate risk
    47.5%