Repository navigation
feat(users): merge duplicate user profiles - #159889
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: blocked before merge. Reviewed September 27, 2026, 7:15 PM ET / 23:15 UTC (Revision 7). ClawSweeper reviewWhat this changesThe branch adds an administrator-only Gateway request and Merge readiness⛔ Blocked before merge - 3 items remain The feature remains useful because current main cannot explicitly merge an email-less profile. The prior method-order finding is fixed and the live proof covers the central flow, but the new RPC can report failure after its SQLite merge has committed if connection refresh throws. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway maps sign-ins and channel identities to durable person profiles in SQLite. An administrator's CLI request reaches the Gateway, which commits a profile merge through the state write worker and then refreshes connected clients. flowchart LR
A[Administrator CLI] --> B[Gateway request]
B --> C[Admin and profile checks]
C --> D[State write worker]
D --> E[SQLite profile merge]
E --> F[Committed profile publication]
F --> G[CLI result and refreshed connections]
Decision needed
Why: The same terminal-response contract is under an open maintainer product decision for Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +229, Tests +444, Docs +116, Other +1. Total +790 across 23 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the existing SQLite merge owner as the sole writer and make the committed survivor result authoritative, isolating fallible connection refresh from the RPC outcome. Do we have a high-confidence way to reproduce the issue? Not applicable as a feature-absence reproduction: current main has no explicit email-less merge path, and the PR supplies a live run of the new flow. The post-commit response finding is source-proven and matches an existing focused report. Is this the best way to solve the issue? The existing SQLite merge owner is the right implementation path, but the new handler must separate a committed merge result from later refresh failures before the solution is complete. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6b890a5e01ec. LabelsLabel changes: No label 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
HistoryReview history (6 earlier review cycles)
|
438fe84 to
ad141c2
Compare
|
@clawsweeper re-review Final head: |
|
🦞👀 Re-review progress:
|
Expose the existing profile merge owner through the admin-only users.merge RPC and openclaw users merge <source> --into <target>. Support email-less duplicates, exact-repeat success, and exact head validation. Preserve merge semantics and historical attribution without changing database or protocol versions. Reuse worker admission/publication and retire affected live authority. Document transfer rules and add registered RPC, CLI, and authority boundary coverage. Regenerate the Android method enum with the protocol generators. Validation: five merge RPC tests (16.55s test time, 79.99s wrapper wall), six CLI tests (3.46s wrapper wall), and three sibling administration tests pass. The Gateway/CLI test graphs and core production types pass. Codex review is scoped-clean through P2. The initial changed-file assertion failure was fixed with runtime validation; remaining native checks were continued separately. Broader test types and core lint encounter two unchanged base-fixture errors already fixed upstream by 0b6f02f (#159836).
ad141c2 to
db6c26d
Compare
|
Merged via squash.
|
|
Post-merge review disposition for the late P2 “Return the committed merge result when refresh fails”: The review was published while the native merge workflow was in progress. It was found during post-merge verification, after the wrapper had merged the exact CI-green head. I inspected the landed source and obtained an independent source check. I am not accepting this as a demonstrated production defect in
These owner implementations are identical in the reviewed head and landed commit. Replacing the entire trusted refresh callback with a throwing stub bypasses the production isolation above. That demonstrates handler sensitivity to a hypothetical callback-contract violation, but does not establish the claimed escaping production refresh/broadcast failure. The callback type is not a formal no-throw guarantee; broader terminal-response policy and sibling paths remain tracked in #127545. This disposition does not close or claim to fix that issue, and no additional production change was made. The method-order P2 is fixed in |
* feat(users): merge duplicate user profiles Expose the existing profile merge owner through the admin-only users.merge RPC and openclaw users merge <source> --into <target>. Support email-less duplicates, exact-repeat success, and exact head validation. Preserve merge semantics and historical attribution without changing database or protocol versions. Reuse worker admission/publication and retire affected live authority. Document transfer rules and add registered RPC, CLI, and authority boundary coverage. Regenerate the Android method enum with the protocol generators. Validation: five merge RPC tests (16.55s test time, 79.99s wrapper wall), six CLI tests (3.46s wrapper wall), and three sibling administration tests pass. The Gateway/CLI test graphs and core production types pass. Codex review is scoped-clean through P2. The initial changed-file assertion failure was fixed with runtime validation; remaining native checks were continued separately. Broader test types and core lint encounter two unchanged base-fixture errors already fixed upstream by 00b1e27 (openclaw#159836). * test(gateway): register users.merge as a current-release method Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
One person can accumulate duplicate Gateway profiles, for example when Cloudflare Access logins use different emails, and administrators cannot currently merge an email-less profile.
Requested by Peter Steinberger for team.openclaw.ai. Today, only
users.linkEmailtriggers a merge when moving the source profile's last email; profiles without email aliases have no equivalent administrative path.User Impact
Administrators can run
openclaw users merge <source> --into <target>(with--jsonwhen needed), backed by the newoperator.admin-onlyusers.mergeRPC. The target remains the surviving person; the source and its existing merge cohort become one-hop tombstones. An exact repeat succeeds without moving aliases again. Redirecting an already-retired source to a different target fails and names its current survivor. The shared Owner profile cannot participate in a merge.The survivor retains its role, display name, primary identity, saved avatar, explicit preferences, and conflicting account selections. Email aliases, provider/channel identities, personal model accounts, GitHub connection state, and source-only preferences follow the existing merge owner's rules. A source avatar transfers only when the survivor lacks one; personal
USER.mdfiles require a manual move.Historical attribution is unchanged: transcripts, creators, assigners, contributors, audit contexts, approvals, publication receipts, and session participants retain their original IDs. Previously captured authority for the retired profile fails closed. Affected connections are disconnected and their role caches invalidated; reconnect to use the survivor's current authority.
No database schema or protocol-version change, migration, or operator Gateway deployment. Release-note context: add explicit administrative merging of duplicate user profiles, including email-less profiles.
Why This Change Was Made
The CLI and RPC reuse the existing
mergeUserProfilesowner through the SQLite write-worker path. Exact-ID validation prevents a stale administrative request from silently selecting a different person. Committed profile publications drive cache invalidation and disconnection, with the response held long enough to acknowledge a merge initiated by the retiring administrator.Follow-ups from identity research: audit exact-ID
session_membersmembership and suggestion ownership checks for alias-aware reads. This change preserves those historical records and does not broaden their access rules or transfer previously captured authority.Evidence
66898a633464;git range-diffand stable patch IDs confirm the reviewed delta is unchanged.pnpm test src/gateway/server-methods.users-merge.test.ts --maxWorkers=1: 5/5 passed; 100.89 seconds wrapper wall, 88.14 seconds Vitest (including fresh worker compilation).pnpm test src/cli/users-cli.test.ts --maxWorkers=1: 6/6 passed; 5.23 seconds wrapper wall, 3.66 seconds Vitest.node scripts/check-changed.mjs: core types, all 25 test-type shards, formatting, and earlier guards passed. The script unused-export scan failed on two pre-existing landing-tool exports; upstream0d02ab7aaf657c1872a5dac32369e88504e3bd5cregisters their actual CLI consumer. Incorporated that fix by a patch-identical rebase; failed and remaining check stages all passed when run directly from the native dry-run command list (including all three export scans, core lint, Android lint, schema, import-cycle, and auth guards).pnpm openclaw --version: development build passed on Node 26.9.0; built head59f5c9d0357c0a7e81a763711b01321644cedb6a.git diff --check: passed. Rebase did not change protocol inputs or the dependency lockfile; existing dependencies remained usable.b6af5be59aee3940580647cdf4fc8e52e494091c. Prior-head ClawSweeper review completed: no actionable findings, no security findings, no before-merge requests, and noRank-up moves:section; no findings were skipped. The authorized refresh completed; refreshed-head ClawSweeper review found no actionable or security findings, and CI exposed the fixture mismatch corrected below. Exact-head CI run36355831495completed successfully (161 successful jobs, 16 skipped). ClawSweeper revision 6 explicitly resolved the method-order P2 and reported no actionable findings. Revision 7, published during native landing, raised a post-commit refresh P2; a post-merge source audit and independent check did not establish the claimed production throw path because the real refresh/publication owners already isolate these errors. The reasoned rejection, remaining callback-contract caveat, and existing shared issue are recorded in the post-merge review disposition. No claim is made that the shared issue is fixed. The native wrapper merged the reviewed head asb1694b364c65666e4b9e9d95814c281228d5c0bf. Initial CI run36350689488failed only insubagent-orphan-recovery.restart-integration.test.ts: four stalerunningassertions received the correctinterruptedstatus; fail-fast cancelled other jobs. A single-file reproduction matched all four failures (23 other cases passed; 81.46 seconds wall). Upstreamb459eb600f238d38f8b7156675e5868751f52c54fixes the assertion after the earlier task-status-to-session-status migration. Incorporated that existing main fix by a patch-identical rebase and started fresh final-head CI; no profile-merge behavior changed.LOC split (added/deleted): production 236/7, tests and fixtures 444/0, docs 118/2, generated Kotlin method registration 1/0; total 799/9 across 23 files. No changelog edits.
Live proof uses a task-owned local Gateway on a free loopback port, isolated state under
.artifacts/c2-live, token auth, synthetic profiles, and disabled channels/providers/schedulers. The email survivor and email-less provider profile were created through the existingensureProfileForEmailandensureProfileForTailscaleIdentityflows before startup; the channel identity was linked over the real RPC. No operator Gateway or real person data was used.Prior CI failure and authorized refresh
Run
36351745576on prior headad141c2e757f863325e5ddb1a8777e1d2d77ee88ended cancelled by fail-fast afterchecks-node-changed-extensions-bundle-34(job108712386321) failed. The actual failure isextensions/codex/src/app-server/native-subagent-completion-delivery.contention.test.ts:140, caserechecks retired-turn-receipt while completion delivery is in flight:vi.getTimerCount()returned 2 rather than 0. Both delivery-count and parent-pin-release assertions passed. The aggregate CI gate also failed.This file, its completion owner, and its fixture harness are unchanged by the feature and current main. One single-file replay passed all 4 cases in 71.63 seconds wall time; that is not evidence of a fix. Shared fixture lifecycle timers are a hypothesis, and the exact ownership of the extra timers remains unproven. The two inspected completed scheduled-main runs (
36348256572and36344472972) did not execute this test; newer scheduled run36351907942was still pending when inspected. No green-main proof for this test was established, so the work order's conditional single REST rerun was not used. The permitted CI-recovery rebase was already used to incorporate the proven orphan-recovery fix.Maintainer follow-up classified this Codex fixture failure as an unrelated intermittent with a separate root-cause investigation and explicitly authorized a refresh instead of rerunning the old head. Rebased onto current main without changing the feature patch;
git range-diffremains identical. On refreshed headdb6c26d04f5cf0b772cb352717e4344150ad621f, the Gateway file passed 5/5 (70.50 seconds wrapper wall; 58.91 seconds Vitest), then the CLI file passed 6/6 (2.46 seconds wrapper wall; 1.31 seconds Vitest). Protocol generators were rerun for upstream protocol changes and left no tracked changes;git diff --checkpassed. Fresh exact-head CI run36353844529completed cancelled by fail-fast. The prior failing extension job passed; a different, PR-caused method-list test failure now blocks landing. No rerun, patch, or merge was attempted after that finding, per the maintainer stop rule. No admin bypass or assertion weakening.Method-order fixture correction
On
db6c26d04f5cf0b772cb352717e4344150ad621f, CI run36353844529failed job108718416024(checks-node-compact-small-11); fail-fast cancelled the remaining jobs and the aggregate gate failed. Two assertions insrc/gateway/server-methods-list.test.tsfail: “appends new methods after model probing while preserving retained older method order” and “preserves the legacy advertised method order.” Production appendsusers.merge, but the expected suffix lists omit it. The feature also insertsusers.mergeintoLEGACY_ADVERTISED_GATEWAY_METHODSinserver-methods-list.test-fixtures.ts, treating the new method as historical. The maintainer subsequently authorized the correction inb6af5be59aee3940580647cdf4fc8e52e494091c(test(gateway): register users.merge as a current-release method): removedusers.mergefrom the frozen legacy fixture and appended it to all three current-release suffix expectations, matching the existing canonical descriptor order. Production code and ordering assertions are unchanged.The refreshed Gateway and CLI focused tests passed (5/5 and 6/6). ClawSweeper reviewed this exact SHA with no actionable findings, no security findings, no before-merge requests, and no
Rank-up moves:section. That review did not override the CI failure; the fixture correction was separately tested and reviewed before publication.Fixture-correction validation ran each file separately with
pnpm test <file> --maxWorkers=1:src/gateway/server-methods-list.test.tssrc/gateway/methods/registry.test.tssrc/channels/plugins/registry.test.tssrc/gateway/method-scopes.test.tssrc/gateway/server-aux-methods.test.tssrc/gateway/server-methods.users-merge.test.tssrc/cli/users-cli.test.ts244 tests passed. The two CI-failing ordering assertions now pass; no assertions were weakened or removed. Targeted formatting and
git diff --checkpassed. The correction is two files, +4/-1; pre-commit Codex autoreview was scoped-clean through P2. Commit-scoped Codex autoreview forb6af5be59aee3940580647cdf4fc8e52e494091calso returned scoped-clean through P2, with no accepted/actionable findings. Hosted CI also passed the repaired assertions: 34 method-list cases reported 0.093 seconds of test execution and all five merge cases reported 3.178 seconds. Their shared CI job completed in 491 seconds including setup and other files. The original isolated live proof remains valid because the correction changes only test expectations.Live CLI transcript (token redacted)