Repository navigation
fix(gateway): owner profile follow-ups - #137022
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 3, 2026, 5:18 AM ET / 09:18 UTC. ClawSweeper reviewWhat this changesRepairs shared Gateway owner-profile merge state, prevents the owner from being treated as a personal identity, and documents the Doctor recovery path. Regression provenancePossible regression — probable (reviewed change; reproduction). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 3 items remain Keep open: this is a bounded, maintainer-directed repair for an unreleased Gateway owner-profile regression, with a fail-closed runtime path and Doctor-owned recovery. Priority: P1 Review scores
Verification
How this fits togetherGateway admission attaches a durable profile to an authenticated connection; that profile then informs role policy, personal GitHub actions, and session visibility. This change keeps the shared-secret owner separate from personal profiles and sends malformed prior state to Doctor for repair. flowchart LR
A[Shared-secret connection] --> B[Gateway admission]
B --> C[Owner profile lookup]
C --> D{State is valid?}
D -->|yes| E[Owner-scoped session and GitHub behavior]
D -->|merged or misdirected| F[Unidentified connection and repair hint]
F --> G[Doctor repair]
G --> C
Before merge
Agent review detailsSecurityNone. PR surfaceSource +242, Tests +872, Docs +2. Total +1116 across 30 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep Doctor as the sole writer for malformed owner state and preserve the fail-closed connection path with the existing canonical-owner regression coverage. Do we have a high-confidence way to reproduce the issue? Yes: the introduced production Gateway WebSocket test creates the malformed owner state, observes rejected personal-profile actions before repair, and observes canonical-owner recovery after Doctor repair. Is this the best way to solve the issue? Yes: the repair normalizes invalid persistent state at Doctor while connection admission remains fail closed, matching the stated maintainer decision and avoiding a runtime compatibility alias. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 74ade6f54c87. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
c72b822 to
d078e7c
Compare
d8949ab to
f7f1c47
Compare
|
Maintainer decision on the merged-owner state (ClawSweeper's "Decision needed" and the four "before merge" items): Doctor owns the repair; the connection path fails closed. Owner rows that unreleased main builds merged into a person (via Scope: this state can only exist on nightly/main installs from the window above; no stable release tag contains the owner profile, so no schema change or schema-version bump is involved. The one remaining ambiguity, a legacy uuid owner binding that an old merge already repointed with no canonical row present, cannot be told apart from a valid legacy binding by the schema and is documented as out of scope. CI: the only failing job on the current head is |
Unreleased owner-profile builds allowed email linking to merge gateway-owner into a person and move gateway.local/owner to that person. Generic profile resolution then followed merged_into, so shared-secret reconnects inherited the person's role, catalog identity, and personal GitHub connection. Guards that checked only resolved IDs also missed the owner tombstone. Restore the raw canonical owner and its provider identity in one profile-write transaction. Reuse a legacy UUID owner only when it is unmerged; otherwise create the canonical owner. Leave the person's emails, role, and GitHub state untouched, invalidate cached aliases after commit, and warn once per repair. Check both raw and resolved IDs at email, role, and verified GitHub mutations. This repairs unreleased state without schema changes or a Doctor migration. Proof: 10 new state regressions failed before the fix; the real-server reconnect regression also reproduced successful tombstone linking and leaked person ID, policy, and GitHub account. All 39 focused owner/reconnect tests now pass. The requested state, gateway, and UI suites pass 270 tests across 16 files. Update the user-model owner paragraph with next-connect repair behavior. Follow-up repair for #137022. Preserve the requested reuse of raw, unmerged legacy UUID bindings. If an old merge already repointed that binding and no canonical owner row exists, the schema has no authoritative original-owner ID to distinguish it from a valid legacy binding; this historical ambiguity remains outside this repair. Validation: node scripts/check-changed.mjs passed, including core/test/UI types, changed-file lint, full-tree dead exports, storage guards, and zero runtime import cycles. git diff --check is clean.
Earlier unshipped owner merges left gateway-owner pointing at a person and moved its local identity. Connection-time recovery repaired durable profile rows during authentication, contrary to the runtime/Doctor ownership boundary. Apply the maintainer decision for #137022: Doctor --fix owns the idempotent repair, while non-fix Doctor reports the finding and recovery hint. Restore the raw canonical owner and local identity atomically, preserve personal emails, roles, and GitHub identities, and invalidate aliases after commit. Reuse an unmerged legacy UUID only when no canonical owner exists. Runtime rejects merged or misdirected owner rows with a typed repair-required error naming openclaw doctor --fix. Existing WS and HTTP catches warn and continue unidentified. Preserve missing-owner creation, name adoption, and all earlier merge, role, GitHub, and canonical-ID guards. No schema change. Proof: pre-change runtime cases returned instead of throwing; Doctor preview and repair sequence omitted the finding/repair; real-server reconnect allowed users.self instead of FORBIDDEN. The requested state/gateway/UI suites plus Doctor preview pass 352 tests across 19 files. The seven migration tests also pass with alias assertions before any runtime writer. Real reconnect proves absent authenticated profile and presence user, the logged Doctor hint, and canonical identity after explicit repair with the person's state preserved. Validation: node scripts/check-changed.mjs, pnpm build, git diff --check, and independent Codex autoreview at P0-P2. Docs describe Doctor repair and reconnect. The existing historical ambiguity of an unmerged UUID identity already repointed to a person with no canonical row remains unchanged.
f7f1c47 to
e8532d1
Compare
Main's #136952 minted the system actor for owner-sender dispatch without updating these expectations, leaving checks-node-compact-small-4 and checks-node-compact-large-16 red on main. Fixed here because this PR is landing on that main.
|
Maintainer response to the current ClawSweeper items (head after the retained-trace commit): Final-effect trace (real behavior proof): the real-server regression in Data-model compatibility: no schema change and no schema-version bump. The Doctor repair only updates existing rows in Production LOC (+242 net across the branch): the growth is the two owner-boundary modules, |
|
Merged via squash.
|
Collapses the model-list cleanup (#135912) and the provider-login branch into one change rebased onto main. - models.list reads one closed catalog source (gateway, prepared, published); the CLI `models list` and chat `/models` consume the prepared catalog directly. - Prepared model runtime: owners publish one curated build, live discovery runs only in the catalog worker, and secret-free provider-auth facts captured at build time replace native readiness reobservation and auth-mode flags. - Provider login: one login runtime shared by the CLI, chat `/login`, Telegram, and the Control UI; `openclaw.setup.auth.start` owns interactive sign-in. - First-run setup inference saves the credential, confirms the in-memory candidate with one tool-free turn, and commits config only on success. - xai catalog derives from the manifest; Codex native auth probes the CLI; doctor repairs legacy model refs and session routes. Integration with main: keeps the worker discovery plan (#137063), worker plugin scoping (#135486), auth order and profile identity (#132450, #137022), the plugin-owned Codex/Claude login readers, and the built-artifact preference for setup revalidation (#136036). Drops main's readiness reobservation (#134524) and stale-refresh catalog mode (#136915): the prepared build already carries the provider-auth facts those paths re-derived. Claude-Session: https://claude.ai/code/session_01CnvVXNnjjQGMrBLYjq29RP
* chore(gateway): deslop owner profile change * fix(gateway): keep the owner profile out of merges, roles, and catalog counts * fix(ui): explain GitHub rows for the shared owner profile * refactor(state): reuse protocol user profile types * fix(state): restore a merged owner profile on connect Unreleased owner-profile builds allowed email linking to merge gateway-owner into a person and move gateway.local/owner to that person. Generic profile resolution then followed merged_into, so shared-secret reconnects inherited the person's role, catalog identity, and personal GitHub connection. Guards that checked only resolved IDs also missed the owner tombstone. Restore the raw canonical owner and its provider identity in one profile-write transaction. Reuse a legacy UUID owner only when it is unmerged; otherwise create the canonical owner. Leave the person's emails, role, and GitHub state untouched, invalidate cached aliases after commit, and warn once per repair. Check both raw and resolved IDs at email, role, and verified GitHub mutations. This repairs unreleased state without schema changes or a Doctor migration. Proof: 10 new state regressions failed before the fix; the real-server reconnect regression also reproduced successful tombstone linking and leaked person ID, policy, and GitHub account. All 39 focused owner/reconnect tests now pass. The requested state, gateway, and UI suites pass 270 tests across 16 files. Update the user-model owner paragraph with next-connect repair behavior. Follow-up repair for openclaw#137022. Preserve the requested reuse of raw, unmerged legacy UUID bindings. If an old merge already repointed that binding and no canonical owner row exists, the schema has no authoritative original-owner ID to distinguish it from a valid legacy binding; this historical ambiguity remains outside this repair. Validation: node scripts/check-changed.mjs passed, including core/test/UI types, changed-file lint, full-tree dead exports, storage guards, and zero runtime import cycles. git diff --check is clean. * fix(state): repair merged owner profiles through doctor Earlier unshipped owner merges left gateway-owner pointing at a person and moved its local identity. Connection-time recovery repaired durable profile rows during authentication, contrary to the runtime/Doctor ownership boundary. Apply the maintainer decision for openclaw#137022: Doctor --fix owns the idempotent repair, while non-fix Doctor reports the finding and recovery hint. Restore the raw canonical owner and local identity atomically, preserve personal emails, roles, and GitHub identities, and invalidate aliases after commit. Reuse an unmerged legacy UUID only when no canonical owner exists. Runtime rejects merged or misdirected owner rows with a typed repair-required error naming openclaw doctor --fix. Existing WS and HTTP catches warn and continue unidentified. Preserve missing-owner creation, name adoption, and all earlier merge, role, GitHub, and canonical-ID guards. No schema change. Proof: pre-change runtime cases returned instead of throwing; Doctor preview and repair sequence omitted the finding/repair; real-server reconnect allowed users.self instead of FORBIDDEN. The requested state/gateway/UI suites plus Doctor preview pass 352 tests across 19 files. The seven migration tests also pass with alias assertions before any runtime writer. Real reconnect proves absent authenticated profile and presence user, the logged Doctor hint, and canonical identity after explicit repair with the person's state preserved. Validation: node scripts/check-changed.mjs, pnpm build, git diff --check, and independent Codex autoreview at P0-P2. Docs describe Doctor repair and reconnect. The existing historical ambiguity of an unmerged UUID identity already repointed to a person with no canonical row remains unchanged. * test(agents): expect the system actor on owner update dispatch Main's openclaw#136952 minted the system actor for owner-sender dispatch without updating these expectations, leaving checks-node-compact-small-4 and checks-node-compact-large-16 red on main. Fixed here because this PR is landing on that main. * test(gateway): trace merged-owner effects before and after doctor repair
What Problem This Solves
Fixes an issue where administrators could merge the shared local owner profile with a personal profile or assign it an operator role, and where adding one identified person to an owner-only Gateway incorrectly activated multi-person catalog restrictions. The owner's Identity page also showed an empty Linked emails row and misleading GitHub retry instructions.
Related: #136819 (durable owner profiles for single-user Gateways).
Why This Change Was Made
The shared owner is attribution and display identity only. This follow-up keeps merge and role rejection at the profile store, maps its typed errors to
INVALID_REQUEST, and applies the existing owner exclusion to catalog counts and visibility. The reserved ID now comes from the public Gateway protocol contract, shared by the store and Control UI.Three follow-ups:
linkEmailpath could later make GitHub sign-in attach an identity to the owner or merge it in either direction; the verified-identity writer now rejects that demonstrated path too.The first commit is behavior-neutral cleanup limited to the landed hunks: shorten the misleading personal-GitHub comment (
src/gateway/server-methods/github-personal-authorization.ts:33) and consolidate two identical provider/owner test fixtures (src/gateway/server-methods/users.test.ts:178, used at:196and:674). No database schema, migration, configuration option, authorization grant, sandbox, recovery, budget, baseline, orCLAUDE.mdchanges.users.linkEmailmergegateway-ownerinto a person, after which generic profile resolution followedmerged_intoand a shared-secret reconnect inherited that person's role, catalog identity, and personal GitHub connection. Per repository policy, legacy persistent state is normalized only by Doctor:openclaw doctor --fixrestores the raw owner row as its own head and re-points thegateway.local/owneridentity (src/state/user-profiles-owner-migration.ts, sequenced beside the Tailscale identity migration; non-fix runs report the finding with the hint). At runtimeensureGatewayOwnerProfilenever resolves through a merge: merged or misdirected owner rows raise a typedrepair-requirederror, WebSocket and HTTP admission continue unidentified with a warning naming the doctor command, and no durable row is mutated on connect. The person keeps their emails, role, and GitHub identities. The email/role/GitHub guards now check both the raw requested id and the resolved id so the owner tombstone cannot be targeted while it exists. No schema change or version bump; no stable release contains the owner profile.User Impact
Owner merge and role requests now return actionable invalid-request errors. Personal profiles retain their existing merge, role, and GitHub behavior. Solo Gateways keep their existing catalog visibility, and shared-owner Identity settings explain how personal GitHub identity becomes available.
Evidence
Retained final-effect trace (commit
98f7cc6ed4f,src/gateway/server/ws-connection/connect-device-pairing.test.ts): with seeded merged-owner state the pre-repair shared-token connection getsFORBIDDENfromusers.github.status/users.github.authorize.startwhile the personal GitHub service spies record zero calls (line 191);sessions.listkeeps the person's creator attribution while the caller stays identityless, system-owned, and unrestricted (206);users.setRole/users.linkEmailongateway-ownerreturnINVALID_REQUESTandusers.listshows the person's role and emails unchanged (235); after the Doctor repair the same client reconnects asgateway-owner, GitHub status succeeds as disconnected for the owner only, and the person's state is preserved (280). The migration import in that test is static so the repo's Vitest filesystem module cache cannot mask it. 9/9 in the file;check-changedgreen; exact-head CI run 33737242523 success.Main breakage fixed in passing (commit
6fd09a7f76f, test-only): #136952 started passingoperatorRoleActor: { kind: "system" }for owner-senderupdate.rundispatch without updating two expectations, leavingchecks-node-compact-small-4andchecks-node-compact-large-16red on main; the expectations now include it.Merged-owner repair proof: seeded merged-owner state fails pre-fix (six runtime cases threw nothing; Doctor preview and sequencing never called the repair; the real-server reconnect returned
users.selfsuccess instead ofFORBIDDEN). Post-fix:src/state/user-profiles-owner-migration.test.ts7 passed (fix, idempotent second fix, personal data preserved, alias cache invalidated), runtime fail-closed 6 passed, doctor preview/sequencing 71 passed, real-server reconnect stays unidentified until the repair runs and attachesgateway-ownerafterwards. Rebased onto current main (516fbb224bfinlined the profile write-transaction wrapper); all branch commits userunOpenClawStateWriteTransactionwith post-commit publication only after an actual write. Final focused run on the rebased head: 351 tests across 19 files;check-changedgreen.The three requested commits and the additional type-only validation fix passed independent Codex autoreview at P0–P2 with no accepted/actionable findings. The validation fix is a fourth commit so the three requested commits remain intact without amending history. Production delta is +76/-38 (+38); tests are +378/-89 (+289); docs +1/-1. Production growth is the requested store exclusions/typed error, catalog exclusion, protocol export, and owner-specific UI copy/branching; no parallel runtime path was added. The initial changed-check found 712 counted lines in
user-profiles.ts(limit 700); reusing the canonical protocol profile type removed duplicated type declarations and brought it within the 700-line limit without a suppression. That final type-only cleanup also passed independent autoreview, 83 focused profile-state tests, and the complete 650-test suite again.Regression proof before each repair:
truefor multiple identities. Cases cover new/existing email links, tombstoned targets, moving one of one/two owner aliases, assigning/clearing roles through direct/tombstoned IDs, and three GitHub attachment/merge directions using old state.UNAVAILABLEinstead ofINVALID_REQUEST; owner-created catalog rows were listable/readable on multi-person Gateways; adding owner attribution invalidated settled enumeration. The error class was present for this isolated mapping proof, while the production mapping and catalog behavior remained unchanged.Exact commands and results:
Final suite split: 83 state tests, 195 Gateway tests, 14 host-account tests, and 358 UI tests. UI build and performance checks passed: startup JS 348,405 B gzip / 8 requests, enforcement limit 350,141 B / 18 requests, headroom 1,736 B; startup CSS 43.6 KiB gzip, limit 45.0 KiB. i18n baseline regeneration found 79 raw-copy entries and 6,204 source keys; no baseline file changed.
node scripts/check-changed.mjspassed (exit 0), including core/core-test/UI typechecks, all dead-export scans (zero entries), changed-file lint, storage guards, and runtime import cycles (zero). Bothgit diff --checkand the full committed-range whitespace check are clean.Visual evidence uses real isolated Chromium and the source Control UI with a mocked Gateway, synthetic owner data, one
users.selfrequest per capture, and zero page errors. Both screenshots were inspected before attachment; this is mocked Gateway browser proof, not live Cloudflare/Tailscale authentication.Deslop findings retained for the author:
src/gateway/server/ws-connection/connect-user-profile.ts:28: removing the non-null assertion safely requires expressing the caller's owner/identified-input relation. A new guard changes failure behavior; another cast would only hide it.src/infra/host-account-name.ts:5,:28,:54: keep cached-failure, login-name suppression, and platform fallback contracts.src/gateway/server-methods/sessions-compaction-checkpoints.ts:119andsrc/gateway/session-recovery-service.ts:275: keep comments explaining inherited sandbox isolation.src/state/user-profiles.owner.test.ts:189: preserve the existing provider-identity reuse behavior. This PR prevents new contamination and rejects GitHub mutations through old owner aliases; it does not reconstruct owner profiles already merged into another ID. Repairing such pre-existing state is separate work.The GitHub path was traced through
applyVerifiedGitHubIdentity,prepareUserProfileGitHubMerge, both merge callers, and the verified alias producers. Clean owner creation has only thegateway.local/owneridentity. Personal GitHub OAuth remains a separate credential connection and does not create a sign-in identity.Exact-head CI run 33717942940 completed skipped at
c72b822d7f0539d31cf19bbc8382efe514a9b7f9; all 31 jobs were skipped..github/workflows/ci.ymlskips draft pull requests. The requested watcher returnedNO-RUN-ATTACHED(exit 13); a skipped run is not executed proof. The PR was confirmedMERGEABLEand remains draft.This PR intentionally remains draft for maintainer review. No merge or landing was performed.