Repository navigation
fix(doctor): keep inherited logins with a non-main owner - #179726
Conversation
Relocate the configured inheritance owner's credentials through Doctor's existing staged migration, while preserving populated main/owner stores with a recoverable warning. Keep copied-state boundaries and source custody, and resolve path aliases without changing runtime ownership registration. Related: #178421 Supersedes: #178684 Co-authored-by: Sukhdeep Johar <[email protected]>
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e4796b39a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| (hasPendingSharedAuthCleanup(env, owner.sourcePath, params) || | ||
| (ownership.location === "legacy-main" && hasCredentials(owner.sourcePath, params))) |
There was a problem hiding this comment.
Check retained ownership before reading the configured store
When the configured non-main owner was already deleted and retained before detection, this condition calls hasCredentials() before retainedSource() checks the deletion journal. If that held database is unreadable or corrupt, detection throws SharedAuthStoreSourceInspectionError, blocking Doctor/update instead of returning the recoverable held-store warning used for main; check retention before inspecting the owner's rows.
AGENTS.md reference: AGENTS.md:L75-L76
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. What this changesDoctor relocates credentials from the configured non-main inheritance owner while preserving private credentials and ambiguous populated stores. Example: The inheritance owner is ops, ops holds fixture:owner, main is empty, and dev has no local login.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Blocked before merge - 5 items remain Keep this PR open: it repairs a current credential-migration bug, but retained-store detection still has an actionable P2 defect. Priority: P1 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherDoctor consumes the selected installation configuration and legacy agent databases, then copies credentials into shared SQLite state, publishes shared ownership, and cleans the recorded source. flowchart TD
A[Selected installation config] --> B[Doctor source detection]
C[Legacy agent stores] --> B
B --> D[Retention and ownership checks]
D --> E[Staged shared state migration]
E --> F[Peer credential resolution]
Technical reviewBest possible solution: Keep the existing staged migration owner, check retention before inspecting either candidate store, and preserve the explicitly limited Doctor scope. Do we have a high-confidence way to reproduce the issue? Current main selects main without consulting the configured inheritance owner; the supplied base-red regressions and stable-upgrade Gateway results support this path, but this review executed no target code. Is this the best way to solve the issue? Repairing source selection inside Doctor's existing migration is appropriate and avoids restoring a competing runtime fallback; the retention check must precede credential inspection. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d84c03e3f52e. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: shipped entry point. SecurityNeeds attention: Candidate-specific rejection proof remains necessary before non-main credentials become fleet-wide. EvidenceSecurity concerns:
What I checked:
PR surfaceSource +97, Tests +161, Docs +2. Total +260 across 7 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 Reviewed October 21, 2026, 4:03 PM ET / 20:03 UTC. |
… 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]>
… 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)
Adapt 21 audited fixes to release-native ownership and recovery. Retain strict temporary environment isolation and provider-only cooldowns. Original-source provenance and contributor credit: #179144 5a97c90 — Peter Steinberger <[email protected]> #180280 442c2f7 — Jason (Json) <[email protected]> #178596 63f386b — Braden Guliano <[email protected]> #181804 d75915e — Peter Steinberger <[email protected]> #181140 b4031b2 — Peter Steinberger <[email protected]> #182207 b8fae65 — Peter Steinberger <[email protected]> #180792 d2c70dd — Peter Steinberger <[email protected]> #179205 c08aa6d — Peter Steinberger <[email protected]> #179997 f178dd9 — mali <[email protected]> #181270 e204484 — Peter Steinberger <[email protected]> #179031 855b0aa — Peter Steinberger <[email protected]> #179726 3d51d00 — Peter Steinberger <[email protected]> #179249 b617d97 — Josh Avant <[email protected]> #182385 bb13bcd — Peter Steinberger <[email protected]> #182615 411bac2 — Peter Steinberger <[email protected]> #181300 765c2f1 — Peter Steinberger <[email protected]> #179549 09ba994 — Peter Steinberger <[email protected]> #179445 ac5587b — Peter Steinberger <[email protected]> #181127 25dde25 — Josh Lehman <[email protected]> #173209 ebccf57 — Peter Steinberger <[email protected]> #175289 e579f09 — Peter Steinberger <[email protected]> Proof: targeted owner/regression tests; Qwen15 and catalog pool13 pass. Final integrated lint/type/format pass remains pending under user direction. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes lost inherited logins after
openclaw doctor --fixwhenagents.defaults.authInheritance.agentIdnames an agent other thanmain.Supersedes #178684, thanks @sukhdeepjohar. Related: #178421.
User Impact
Doctor relocates the configured owner's credentials when that owner has credentials and
mainhas none. Peers can then use the configured shared login; their private credentials stay local. If both stores contain credentials, Doctor preserves both and reports a recoverable warning explaining how to retry.This corrects the documented inheritance contract: affected peers can gain access to their configured owner's credentials after relocation, where released runtimes previously used main or had no credential. Fresh-store bootstrap and installations that already completed the shared-state cutover remain outside this repair.
Why This Change Was Made
The existing staged migration always selected main's database. The repair supplies Doctor's selected configuration to that same migration owner, checks both possible sources against copied-state boundaries, and carries the selected agent identity through source reads and cleanup. Retained deleted stores remain protected, including deletion after detection. Physical directory aliases are compared without registering a different runtime owner.
The copy, ownership publication, cleanup, conflict checks, and receipts retain their existing owners. No config option, dependency, database schema, or runtime auth fallback is added. Production: +132/-35 (net +97); tests: +159/-2 (net +157); docs: +2. The necessary growth is source selection and preservation checks within the existing migration.
Evidence
CI typing follow-up: reproduced TS2322 in
test/tsconfig/tsconfig.core.test.state-logging.json, then typed the shared-auth fixture environment asNodeJS.ProcessEnv(no cast or suppression).node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.state-logging.json --noEmitnow passes.OPENCLAW_VITEST_RUNTIME=nodeandOPENCLAW_VITEST_RUNTIME=bun, each withnode scripts/run-vitest.mjs src/infra/state-migrations.shared-auth-store.test.ts --maxWorkers=1, both pass: 32 passed / 1 existing Linux-only skip. Runner times: 47.00 s Node / 33.28 s Bun. All used isolated HOME/state under the worktree. Targeted type-aware lint, formatting, diff checks, and Codex autoreview pass. Follow-up delta: production +0/-0; test +5/-1.Regressions on main
c5471a5ffd8dfailed for standard/custom owner directories, the main-directory override, two populated stores, and the copied snapshot boundary. The alias regression also caught and now protects against reverse-owner registration during source selection.Bun:
OPENCLAW_VITEST_RUNTIME=bun node scripts/run-vitest.mjs src/infra/state-migrations.shared-auth-store.test.ts src/infra/state-migrations.caller-mode.refusal.test.ts src/infra/state-migrations.retained-deleted-agent.test.ts --maxWorkers=1— 65 passed, one existing Linux-only POSIX-lock case skipped on macOS; 87.84 seconds total.Core and infra-test typechecks, targeted type-aware oxlint/oxfmt,
git diff --check, and the import-cycle check pass. Codex autoreview found no actionable P0/P1 findings. The full SQLite inventory incheck:changedwas not run locally because of its known 20–40+ minute host stall; PR CI remains the broad gate.Live upgrade: installed published
[email protected]in an isolated prefix and savedfixture:ownerusing itsmodels auth paste-api-key --provider fixture --profile-id fixture:owner --agent opscommand. The candidate'spnpm openclaw doctor --fix --non-interactive --no-workspace-suggestionsupgraded that stopped synthetic state from shared/agent schemas 20/25 to 30/31, moved the owner profile, recorded the ops source path, and cleaned the local auth row.Started
pnpm openclaw gateway run --port 62382 --bind loopbackon the upgraded state. Twopnpm openclaw agent --agent dev --message <request> --jsonturns (requests:Reply AUTH_OK only.andReply AUTH_OK again.) returnedstatus: okandAUTH_OK; the local OpenAI-compatible model server observed the expected owner credential on both requests. Agent-reported durations: 929 ms and 141 ms. The Gateway and model server were stopped after proof.All live commands used isolated HOME, config, and state directories under this worktree. A stopped pre-upgrade copy was retained before mutation. Doctor's automatic original-state capture warned about this host volume's writable ancestor; that host limitation did not prevent migration, and no operator state was used.
Node: all 40 directly importing test files passed, with 481 passed / 4 existing skips, across six Vitest shards in 1135.74 seconds. The skips are three opt-in PostgreSQL integration cases and the Linux-only POSIX-lock case. The caller list was collected and run in its original order:
Reported test time for the touched files (Node / Bun, excluding shared preparation): shared-auth store 34.81 / 22.37 s, copied-plan refusals 31.69 / 15.29 s, retained deleted agents 71.52 / 38.35 s. These exercise real SQLite migration and custody; the new retired-owner case takes about one second. No individual test exceeded 30 seconds, and no test file exceeded 120 seconds of test time. No flaky failure was observed. Initial PR CI caught the fixture typing error corrected above.