Repository navigation
feat(gateway): durable owner profile for single-user gateways - #136819
Conversation
Token/password (and other unidentified) operator connections had no user profile, so the Control UI footer showed the literal "Account", the footer menu had no profile entry, and Settings > Profile rendered no Identity section. Only trusted-proxy and Tailscale sign-ins produced a profile. Root cause: connect-session derived authenticatedUserId only from authResult.user; profile-page renderIdentity() returned nothing without a self user; the identity menu omitted its header. Owner: connection identity admission (connect-session / http auth user profile) plus the profile store. Fix: ensure one durable local owner profile (provider gateway.local, subject owner, existing user_profile_identities table; no schema change, no config option) for operator connections with no authenticated user id, limited to token/password when gateway.roles is configured. Seed an unset display name once from the host account's full name (macOS id -F/dscl, Linux GECOS; never the login name); edits are never overwritten. Device token reconnects resolve to the same profile. users.self, presence projection/refresh, online timing, and the personal GitHub gate now key on the attached profile; a shared-secret system actor with an owner profile is the person and may use My GitHub. Owner attribution grants no scopes; identity scopes still use only the verified upstream user id. Profile resolution failure continues unidentified. UI: "Owner" fallback label, identity menu always shows the profile header, Profile page explains unidentified connections. Split http-auth-user-profile.ts and connect-user-profile.ts out of their 700-line owners. Proof: focused gateway/state/UI vitest suites, check-changed, build, Codex autoreview scoped-clean, real-server regression failing pre-fix with "users.self requires an authenticated user", live rename + device-token reload + gateway restart on an isolated dev gateway.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 2, 2026, 11:55 PM ET / September 3, 2026, 03:55 UTC. ClawSweeper reviewWhat this changesThis PR gives eligible single-user Gateway connections one durable local owner profile, surfaces it in the Control UI, and preserves existing shared-secret system authority through HTTP, tools, and session paths. Merge readiness⛔ Blocked before merge - 4 items remain Keep open. Current main still lacks the durable owner-profile behavior, and the prior HTTP-authority blocker is repaired at this head; the remaining merge decision is whether shared-secret holders should intentionally share one durable profile and its personal GitHub connection. Priority: P2 Review scores
Verification
How this fits togetherGateway authentication establishes the connection facts used by the profile store, session policy, and Control UI. This change adds a durable local profile for single-user shared-secret operators while keeping authorization decisions separate from that attribution. flowchart LR
A[Shared-secret operator] --> B[Gateway authentication]
B --> C[Owner profile resolver]
C --> D[Profile storage]
C --> E[HTTP and WebSocket clients]
E --> F[Session and GitHub policy]
E --> G[Control UI profile]
Decision needed
Why: This is a deliberate default identity and credential-ownership model for existing shared-secret deployments, not a mechanical correctness choice. Before merge
Agent review detailsSecurityNone. PR surfaceSource +217, Tests +1040, Docs +9. Total +1266 across 70 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Adopt the owner-profile flow only with explicit acceptance that shared-secret access is one shared trust domain; retain the separate system-actor authority path and the documented per-person sign-in alternative. Do we have a high-confidence way to reproduce the issue? Yes from source: current main leaves unidentified shared-secret HTTP connections profile-less, while this branch attaches the durable owner profile; this read-only review did not execute the UI flow. Is this the best way to solve the issue? Unclear pending product direction. The implementation keeps attribution separate from authority and repairs the prior HTTP regression, but maintainers must choose whether the shared-owner identity model is the desired default. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ae21338266a7. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Owner attribution displaced principal recovery, system-actor authority, and identityless sharing semantics, causing person-role sandbox and visibility policy to affect shared-secret and no-auth operators. Use gateway-owner for newly inserted owner profiles while retaining the existing provider/subject identity lookup and idempotent reuse. Exclude that attribution from person roles and sharing identity. Carry HTTP authentication's system actor into nested dispatch, and retain inherited sandbox requirements for owner-attributed checkpoint branches and restart recovery. Remove sandbox actor threading and the redundant sessions-list cache key. Preserve owner presence, sender/creator attribution, profile preferences, personal GitHub eligibility, and the existing Control UI size trims. PR #136819. No schema, budget, or baseline changes. Validation: requested owner/WS/HTTP/session/UI suites passed 1,599 tests before four redundant cache cases were removed. Final cache suite: 31; recovery suite: 29; repaired neighboring mocks: 55. All 63 changed core/UI TypeScript files passed typed lint. Full check-changed passed, and fresh Codex autoreview reported no actionable P0 findings.
|
Maintainer decision (recording the ClawSweeper rank-up move and the four "before merge" items): Shared owner semantics: accepted. On a single-user Gateway every holder of the shared token or password is the same person, so they intentionally share one durable owner profile: its display name, avatar, per-profile preferences, and, if the owner connects one, the My GitHub connection. This is the default we want for the out-of-box path. Teams that need per-person identity use Cloudflare Access, Tailscale Serve, or a trusted proxy; the docs in this PR say so explicitly ( My GitHub contract: the owner profile is a person and may connect My GitHub. A system actor without a profile stays ineligible; synthetic and agent-tool callers stay excluded. Owner attribution never grants scopes, never changes operator-role policy, sandbox requirements, recovery scope, or session-sharing visibility (second commit, canonical id Data-model compatibility: no schema change and no schema-version bump. The owner is one row in the existing Follow-ups recorded, not blockers: admin email linking can merge into or out of the reserved owner profile (merge policy decision); catalog visibility counts profiles independently of sharing identity; the Identity rows' "Refresh to retry" copy predates this change. |
|
Merged via squash.
|
…aw#136819) * feat(gateway): durable owner profile for single-user gateways Token/password (and other unidentified) operator connections had no user profile, so the Control UI footer showed the literal "Account", the footer menu had no profile entry, and Settings > Profile rendered no Identity section. Only trusted-proxy and Tailscale sign-ins produced a profile. Root cause: connect-session derived authenticatedUserId only from authResult.user; profile-page renderIdentity() returned nothing without a self user; the identity menu omitted its header. Owner: connection identity admission (connect-session / http auth user profile) plus the profile store. Fix: ensure one durable local owner profile (provider gateway.local, subject owner, existing user_profile_identities table; no schema change, no config option) for operator connections with no authenticated user id, limited to token/password when gateway.roles is configured. Seed an unset display name once from the host account's full name (macOS id -F/dscl, Linux GECOS; never the login name); edits are never overwritten. Device token reconnects resolve to the same profile. users.self, presence projection/refresh, online timing, and the personal GitHub gate now key on the attached profile; a shared-secret system actor with an owner profile is the person and may use My GitHub. Owner attribution grants no scopes; identity scopes still use only the verified upstream user id. Profile resolution failure continues unidentified. UI: "Owner" fallback label, identity menu always shows the profile header, Profile page explains unidentified connections. Split http-auth-user-profile.ts and connect-user-profile.ts out of their 700-line owners. Proof: focused gateway/state/UI vitest suites, check-changed, build, Codex autoreview scoped-clean, real-server regression failing pre-fix with "users.self requires an authenticated user", live rename + device-token reload + gateway restart on an isolated dev gateway. * fix(gateway): keep the owner profile attribution-only Owner attribution displaced principal recovery, system-actor authority, and identityless sharing semantics, causing person-role sandbox and visibility policy to affect shared-secret and no-auth operators. Use gateway-owner for newly inserted owner profiles while retaining the existing provider/subject identity lookup and idempotent reuse. Exclude that attribution from person roles and sharing identity. Carry HTTP authentication's system actor into nested dispatch, and retain inherited sandbox requirements for owner-attributed checkpoint branches and restart recovery. Remove sandbox actor threading and the redundant sessions-list cache key. Preserve owner presence, sender/creator attribution, profile preferences, personal GitHub eligibility, and the existing Control UI size trims. PR openclaw#136819. No schema, budget, or baseline changes. Validation: requested owner/WS/HTTP/session/UI suites passed 1,599 tests before four redundant cache cases were removed. Final cache suite: 31; recovery suite: 29; repaired neighboring mocks: 55. All 63 changed core/UI TypeScript files passed typed lint. Full check-changed passed, and fresh Codex autoreview reported no actionable P0 findings.
What Problem This Solves
On a single-user Gateway (token or password auth, the default install) the Control UI sidebar footer showed the literal fallback Account, the footer menu had no profile entry, and Settings → Profile rendered no Identity section at all. There was no way to set a display name or avatar. Only trusted-proxy and Tailscale sign-ins produced a user profile, so the overwhelmingly common single-operator setup had no identity to name and no explanation of why.
Why This Change Was Made
The unidentified operator on a shared-secret Gateway is the owner. Instead of leaving that connection profile-less, the Gateway now ensures one durable local owner profile for it (provider
gateway.local, subjectowner, stored through the existinguser_profile_identitiestable; no schema change, no config option). The profile is seeded once from the host account's full name (macOSid -F/dscl, Linux GECOS; never the login name, so service accounts do not leak into labels) and is editable through the normal Identity section. All tabs and devices using the shared secret, including device-token reconnects, resolve to the same profile, so the name follows the person.Gate: operator role, no authenticated user id, and either no
gateway.rolesconfigured or a token/password method (the existing shared-secret owner notion). Node, ephemeral CLI/backend/probe, and synthetic clients are excluded. Owner attribution never grants scopes; identity scopes still use only the verified upstream user id. If profile storage fails the connection continues unidentified exactly as before.Consumers that gated on an email user id now key on the attached profile:
users.self, presence projection, presence refresh, online timing. The shared-secret "system actor" marker no longer blocks My GitHub when an owner profile is attached (a system actor without a person stays ineligible).UI: the fallback label is now Owner (only reachable for genuinely unidentified connections), the identity menu always shows the profile header so Profile stays reachable, and the Profile page explains an unidentified connection instead of rendering nothing.
Attribution-only contract (second commit): the owner profile has the canonical id
gateway-owner. Operator-role policy, implicit operator actors, and session-sharing identity exclude that id, so shared-secret, device-token, and no-auth connections keep their pre-existing owner-equivalent visibility and never pick up person-role sandbox requirements; the hello recovery principal derives only from an upstream-verified identity; and the shared-secret system actor is recorded once at the HTTP auth boundary and carried into tool dispatch and session creation instead of being re-derived from "no profile". Checkpoint branches and restart recovery stamped with the owner creator inherit the source sandbox requirement.Opportunistic:
http-auth-utils.tsandconnect-session.tscrossed the 700-line lint limit, so their profile-resolution owners moved tohttp-auth-user-profile.tsandconnect-user-profile.ts.User Impact
Docs:
docs/concepts/user-model.md,docs/web/control-ui.md,docs/concepts/multi-user.md,docs/web/notifications.md,docs/cli/skills.md,docs/start/teams.md.Evidence
Root cause:
connect-session.tsderivedauthenticatedUserIdonly fromauthResult.user; profile-pagerenderIdentity()returnednothingwithout a self user; the identity menu omitted its header. Architectural owner: connection identity admission (connect-session.ts/http-auth-user-profile.ts) plus the profile store (user-profiles.ts).Production LOC: +311 −124 in the feature commit (host-account lookup, owner ensure, shared gate, two owner-boundary file splits) and +84 −54 in the attribution-only fix. Tests +955 −144 and +750 −521. Docs +18 −9.
Local proof (worktree, Node 26):
node scripts/run-vitest.mjs src/state/user-profiles src/gateway/server/ws-connection src/gateway/http-auth-utils src/gateway/server-methods/users src/gateway/authenticated-presence-user src/infra/host-account-name src/gateway/server/client-presence src/gateway/server-request-context→ 29 files / 368 tests + 14 passednode scripts/run-vitest.mjs src/gateway/server-methods/users-github src/gateway/github-personal-publication src/gateway/http-auth-utils src/gateway/server-request-context src/gateway/server/ws-connection/connect-device-pairing.test.ts→ 5 files / 130 passednode scripts/run-vitest.mjs ui/src/components/app-sidebar ui/src/pages/profile→ 6 files / 356 passednode scripts/check-changed.mjs→ pass (format, typecheck, lint, dead-export scan)pnpm build→ clean667ed8b63b6→ all 161 jobs green (11 skipped)connect-device-pairing.test.tsfails on the starting source withFORBIDDEN: users.self requires an authenticated user; the My GitHub owner checks fail pre-fix withMy GitHub requires a current authenticated human Gateway connection.Data-model compatibility: no schema change and no schema-version bump. The owner profile is one ordinary row in the existing
user_profilestable plus one row in the existinguser_profile_identitiestable (providergateway.local, subjectowner), written through the sameensureProfileForProviderIdentitytransaction Tailscale identities use. It is created lazily on the first eligible connect, so no migration ordoctor --fixstep is needed. Older Gateway builds reading the same state database treat it as one more provider identity they never resolve, and a downgrade leaves the rows inert; deleting them only causes a fresh owner profile on the next connect.src/state/user-profiles.owner.test.tscovers the durable mapping, seed-only-when-empty, and provider separation from Tailscale's dotless provider namespace. The host-account-name lookup caches its result in process memory only; nothing about it is serialized or persisted.Live proof on an isolated dev Gateway (
OPENCLAW_STATE_DIRscratch dir, own port, token auth, no model configured): footer seeded with the host account's full name; rename through the Identity form; reload reconnects via the cached device token and shows the new name; the name survives a Gateway restart;users.github.statussucceeds for the owner.Before
After
Follow-up (not in this PR): the Identity rows "GitHub account: Refresh to retry" and "Git co-author credit: Refresh to retry" read as retryable for profiles that never get GitHub-backed sign-in (owner, plain email proxies); the copy predates this change.