Repository navigation
fix(doctor): agents lose inherited logins after doctor when the auth inheritance owner is not main - #178684
fix(doctor): agents lose inherited logins after doctor when the auth inheritance owner is not main#178684sukhdeepjohar wants to merge 4 commits into
Conversation
While shared auth is legacy-main, peers inherit the store of agents.defaults.authInheritance.agentId, not main's. Doctor always relocated main's store and then disabled inheritance, so an owner's credentials stayed local and peers lost them. Relocate the configured owner's store when main holds no credentials, keep relocating main when the owner holds none, and skip with a recoverable warning when both hold credentials, since a single-source move would drop one side. Copied-update planning now checks both candidate sources.
|
🦞👀 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. What this changesDoctor selects the configured non-main auth inheritance owner's credentials for relocation and skips ambiguous two-store layouts. Example: authInheritance.agentId is ops, only ops has mock:ops, and dev has no login.
Review scores
ProductKind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Partial Merge readiness⛔ Blocked before merge - 1 item remains This PR contains useful Doctor repair work and resolves the previous finding; accepting its change to which credentials peers receive needs an explicit owner decision. Priority: P1 Decision needed
Before merge
FindingsNone. Agent review detailsHow this fits togetherDoctor reads the selected installation's configuration and legacy agent databases, then copies shared credentials, commits shared ownership, cleans source rows, and records migration receipts. flowchart TD
A[Selected installation configuration] --> B[Doctor source selection]
C[Main and configured owner stores] --> B
B --> D[Conflict and source authority checks]
D --> E[Existing staged relocation]
E --> F[Shared state credentials and receipts]
F --> G[Peer agent authentication]
Technical reviewBest possible solution: Use the existing staged Doctor relocation with an explicitly accepted configured-owner credential policy, while retaining separate tracking for bootstrap and previously switched installations. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically selects main regardless of the configured inheritance owner, and the contributor supplies matching stable-upgrade Gateway traces; this review executed no target code. Is this the best way to solve the issue? The implementation repairs source selection in the existing migration owner, preserves private peer stores and canonical ownership, and adds distinct snapshot, alias, and retired-source protections without a parallel fallback. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0f46faecf63c. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +109, Tests +262, Docs 0. Total +371 across 7 files. Added test files: 0. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)
Reviewed October 20, 2026, 4:37 PM ET / 20:37 UTC (Revision 3). |
…before relocation Compare the configured owner's store with main's by physical database identity, so an owner agentDir that links to main's directory is not reported as a second credential store. Recheck the retained-agent matcher under the migration lock before copying, so a source agent deleted after detection is never relocated or cleaned.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
The physical identity check for the configured owner's store ran before the non-repair early return, so an unreadable owner agentDir made ordinary detection throw. Resolve only path names up front and compare physical identity in the repair-only source selection.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…cation The point-of-effect recheck treated an unreadable deletion journal as a held source, so a relocation without a preceding detection pass in that state was skipped. Detection already refuses an unreadable journal; under the lock only a deletion recorded since detection blocks the copy.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
… not main (#179726) Doctor relocated main's credential store regardless of the configured auth inheritance owner, so agents lost inherited logins. The existing migration now selects the configured owner, preserves conflicting stores with a warning, and protects private credentials and deleted-agent state. Supersedes #178684, thanks @sukhdeepjohar. Co-authored-by: Sukhdeep Johar <[email protected]>
|
Thank you @sukhdeepjohar! You were right that Doctor ignored a non-main auth inheritance owner and agents lost inherited logins. We re-implemented the fix in #179726, which landed with you credited as co-author. Closing this one as superseded. |
… not main (openclaw#179726) Doctor relocated main's credential store regardless of the configured auth inheritance owner, so agents lost inherited logins. The existing migration now selects the configured owner, preserves conflicting stores with a warning, and protects private credentials and deleted-agent state. Supersedes openclaw#178684, thanks @sukhdeepjohar. Co-authored-by: Sukhdeep Johar <[email protected]>
|
Thanks @steipete for getting this fixed and landed ! |
… not main (#179726) Doctor relocated main's credential store regardless of the configured auth inheritance owner, so agents lost inherited logins. The existing migration now selects the configured owner, preserves conflicting stores with a warning, and protects private credentials and deleted-agent state. Supersedes #178684, thanks @sukhdeepjohar. Release adaptation: stable lacks the integrityCheck option on the shared auth source reader/cleanup, so ownerId is threaded without it. The main test-file refactor (top-level helpers) does not exist on stable; the new owner/conflict/alias cases live in state-migrations.shared-auth-store.inheritance-owner.test.ts, and the deleted-owner case uses stable fixtures (createLegacyDatabaseFixture + deletion journal). Co-authored-by: Sukhdeep Johar <[email protected]> (cherry picked from commit 3d51d00)
Related: #178421
Fixes the Doctor path, which is how the reporter's install was switched over (its ledger names main's store as the Doctor source). The fresh-install switch-over has the same mismatch and remains open under #178421; it needs a separate change because that code cannot see the config.
What Problem This Solves
Fixes: agents lose an inherited login after
openclaw doctor --fixwhenagents.defaults.authInheritance.agentIdnames an agent other thanmain. Doctor movedmain's login store into shared state and turned inheritance off, so the owner kept its login and every other agent had none.User Impact
mainholds none. Other agents can then use the owner's logins, which is whatauthInheritancedocuments.main's store; see Details). So for these installs, other agents get the owner's logins for the first time after this Doctor run. Agents' own private logins are not copied.mainand the owner hold logins, Doctor skips this one move with a recoverable warning naming both stores, and the install keeps its current layout and behavior.main,OPENCLAW_AGENT_DIRrelocation, installs whose owner holds no logins (mainstill moves), and the existing refusal to delete the configured owner.Why This Change Was Made
Until the move, the configured owner is the documented inheritance source, so the move carries the owner's store. Doctor picks the source from its own selected config, refuses to choose when both stores hold logins, and re-checks the source right before copying. The copied-update planner checks the owner's store against its snapshot boundary too.
Example of the fresh-install path left open (
shared-store-bootstrap*.ts): on 2026.10.5,openclaw models auth paste-api-key --agent mainon such an install switches the store over and leaves the owner's logins behind.Details
sourceConfigBeforeMigrations ?? cfgviaresolveLegacyInheritedAuthAgentId/resolveLegacyInheritedAuthAgentDir; there is no process-wide config fallback.agentDirismain's directory, directly or through a symlink, is treated asmain(isSameOpenClawAgentDatabasePath). This check runs only in the repair path; outside Doctor repair, detection still returns before touching any source file.main's key, while the upgraded config names the owner. Moving either store alone would change which credential peers use, so Doctor leaves it to the operator. An unreadable store payload counts as holding logins.run/auth-plan.tsloads an agent's store without the inherited directory, so turns fall back tomain's store. That is a separate runtime issue, not changed here.OPENCLAW_AGENT_DIRstill relocates onlymain's store, which matches how the owner'sagentDiris resolved.Evidence
Isolated containers, network off, and a fake OpenAI-compatible model server that records the key it receives and returns 401 unless it gets the owner's key. Each run first checked that the built output contains this branch's code.
Upgrade from stable 2026.10.5 (login only on
ops,authInheritance.agentId: "ops", agentsopsanddev), then twoopenclaw agent --agent devturns through a real Gateway:devturnsagents/main/agent/openclaw-agent.sqlite(does not exist);opskeepsmock:opsauth=<none>[mock:ops]; owner's local copy cleaned; ledger sourceagents/ops/agent/openclaw-agent.sqliteAUTH_OK,AUTH_OKBearer <owner key>Real Gateway proof: direct upgrade from 2026.7.1
Direct upgrade from 2026.7.1 (default agent
ops; logins added with 2026.7.1's own CLI). On 2026.7.1 itself,devsent no key when onlyopshad one, and sentmain's key whenmainalso had one.devsendsdevsendsopsonlyBearer <owner key>,AUTH_OKopsandmainmain's keymain's key (as on 2026.7.1)Real CLI proof: authority checks (2026.10.5-built state)
Real Doctor proof: rejection after detection
Fresh install on this branch's build, login on
opsonly (old layout). Doctor's shared-auth detect and migrate functions, with the owner retired or reassigned in between:Regression tests. These fail on
main(or on an earlier commit of this PR, for the review fixes) and pass here:agentDir(peer's own store stays private)OPENCLAW_AGENT_DIRset, the configured owner's store still movesagentDirsymlinked tomain's directory is treated asmainstate-migrations.retained-deleted-agent.test.ts)agentDir(noEACCES)Guards for unchanged behavior: an owner with no logins →
mainmoves as before; an owner database recorded for another agent → refused, untouched.Checks:
pnpm tsgo:coreandpnpm tsgo:core:testpass.oxlinton the changed files: 0 warnings, 0 errors. A wider run of 112 related test files fails only in suites that fail identically on unmodifiedmainin the same container: terminal-UI PTY timeouts,.clawdbot→.openclawrename tests, and a few timing-sensitive suites.pnpm check:changedpasses typecheck-all, import cycles, plugin boundaries and the database-first guard. Its remaining failures are outside this change:max-linesin untouched files, the existing core test-shard root budget, and two steps that need network.