Skip to content

refactor(doctor): unify legacy auth migration ownership - #117361

Merged
steipete merged 1 commit into
mainfrom
codex/goal100k-doctor-auth-owner-0801-2d45
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/goal100k-doctor-auth-owner-0801-2d45

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Operators upgrading legacy auth profiles encountered different Doctor repair paths depending on whether they ran interactive Doctor or openclaw doctor --fix. The older flat-profile, API-key alias, and OpenAI-provider repair paths rewrote or removed persistent credential sources outside the durable SQLite migration receipt owner, creating inconsistent archives and unnecessary upgrade-recovery complexity.

Why This Change Was Made

Both Doctor entry points now use one receipt-backed SQLite auth migration owner. It resolves OAuth sidecars before import, folds historical openai-codex profiles and references into openai, preserves canonical credentials and SecretRefs, verifies imported state, and archives the untouched original bytes; migration ledger writes reuse the existing shared receipt primitives.

User Impact

Existing stable and beta installations retain their auth profiles, provider identity, profile order, API keys, SecretRefs, and original recovery archives through one consistent Doctor upgrade flow. Interrupted or repeated repairs remain recoverable and idempotent, with the same public CLI and no new configuration, runtime compatibility path, or SQLite schema change.

Evidence

  • Handwritten production: 87 added, 510 deleted; net -423 lines.
  • Existing shipped upgrade paths inspected in v2026.7.1, v2026.7.2-beta.6, and v2026.6.33.
  • Blacksmith Testbox tbx_01kyye2jhmr4yrpbmr11cvng85: 188 tests passed across seven focused suites:
    pnpm test src/commands/doctor-auth-flat-profiles.test.ts src/commands/doctor-auth-canonical-api-key-alias.test.ts src/commands/doctor-auth-migration-receipts.test.ts src/commands/doctor-auth-migration-inherited-oauth.test.ts src/commands/doctor-auth-oauth-sidecar.test.ts src/commands/doctor/repair-sequencing.test.ts src/flows/doctor-health-contributions.test.ts
  • Real isolated Linux operator proof ran pnpm openclaw doctor --fix --non-interactive twice against a copied legacy OAuth/API-key fixture; both runs produced:
{"phase":"first","provider":"openai","profiles":["openai:work","openrouter:default"],"archiveCount":1,"archivePreservesOriginalBytes":true,"receiptStatus":"completed","receiptCount":1,"sourceRemoved":true}
{"phase":"repeat","provider":"openai","profiles":["openai:work","openrouter:default"],"archiveCount":1,"archivePreservesOriginalBytes":true,"receiptStatus":"completed","receiptCount":1,"sourceRemoved":true}
  • Remote pnpm check:changed covers formatting, dead exports, architecture guards, production/test typechecks, and lint.
  • Fresh AI-assisted structured autoreview: gpt-5.6-sol, reasoning xhigh, TruffleHog clean, no actionable findings.
  • Exact-head GitHub CI run 30696615396 and its openclaw/ci-gate both completed successfully for 2747d785d243dffbe6036b7a28ae98eafa59e848.
  • Moving-main disposition: merge base aa2a5c96f69a1be639c602649d4aa2e4de8da0a8 through locally observed origin/main 4e47c4cabf8f2901ec781b59d059999211398813 changes none of this PR's nine touched files; no owner-boundary overlap, conflict, rebase, or proof refresh is needed for that main movement.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XL maintainer Maintainer-authored PR labels Aug 1, 2026
@steipete
steipete marked this pull request as ready for review August 1, 2026 10:54
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 7:30 AM ET / 11:30 UTC.

ClawSweeper review

What this changes

The PR replaces separate flat-profile, API-key alias, and legacy openai-codex store repairs with one verified, receipted SQLite auth-profile migration used by interactive Doctor and openclaw doctor --fix.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No blocking correctness or security finding. This PR moves legacy auth-file normalization into the existing receipt-backed SQLite migration owner, which is the cleaner owner boundary; it remains open because the maintainer label protects a compatibility-sensitive credential migration for human merge review. Likely related people: steipete (high-confidence current feature owner).

Priority: P2
Reviewed head: 2747d785d243dffbe6036b7a28ae98eafa59e848

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong focused regression coverage, exact-head CI, and a repeated real Doctor migration run support a clean owner-boundary consolidation.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body includes a real isolated Linux openclaw doctor --fix --non-interactive run twice against a legacy OAuth/API-key fixture, showing canonical provider/profile output, preserved original archive bytes, a completed receipt, source removal, and idempotence.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body includes a real isolated Linux openclaw doctor --fix --non-interactive run twice against a legacy OAuth/API-key fixture, showing canonical provider/profile output, preserved original archive bytes, a completed receipt, source removal, and idempotence.
Evidence reviewed 6 items Canonical migration owner: The branch canonicalizes legacy API-key aliases and legacy OpenAI Codex profile IDs before importing, verifies the authoritative SQLite result inside the write transaction, and only then archives the source receipts.
Both Doctor entry points converge: The branch runs OAuth sidecar repair before the canonical migration in both the non-interactive repair sequence and the interactive auth-profile health contribution, removing the separate legacy repair calls.
Shared receipt contract: The migration-receipt adapter replaces its local ledger upserts with the existing shared receipt helpers, preserving the established run/source ownership contract rather than adding a parallel receipt format.
Findings None None.
Security None None.

How this fits together

Doctor is OpenClaw’s upgrade and recovery path for persisted operator state. Both the interactive health flow and non-interactive repair sequence process legacy auth files, migrate usable credentials into per-agent SQLite storage, then archive the original source only after verification.

flowchart LR
  A[Legacy auth profile files] --> B[Doctor health flow]
  A --> C[Doctor --fix repair sequence]
  B --> D[OAuth sidecar repair]
  C --> D
  D --> E[Receipt-backed SQLite migration]
  E --> F[Canonical auth profiles]
  E --> G[Verified source archive]
  F --> H[Doctor repair outcome]
Loading

Before merge

  • Resolve merge risk (P1) - This is an upgrade-time credential migration: a rare legacy profile combination could still expose an archive, provider-ID, or precedence edge case not represented by the focused fixtures, even though the branch verifies SQLite state before removing sources.
  • Resolve merge risk (P1) - The PR intentionally changes ownership of persisted legacy auth repair under a protected maintainer label; a human owner should confirm the upgrade contract before merge rather than treating green checks as the only gate.
  • Complete next step (P2) - No mechanical repair is identified; the protected maintainer label and compatibility-sensitive credential migration need Doctor/auth owner merge review.
Agent review details

Security

None.

PR surface

Source -423, Tests -205. Total -628 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 5 87 510 -423
Tests 4 145 350 -205
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 232 860 -628

Review metrics

Metric Value Why it matters
Legacy repair ownership 3 standalone repair paths removed; 1 receipt-backed migration owner retained A single archive-and-verification owner reduces divergence between interactive Doctor and doctor --fix upgrades.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-auth-canonical-api-key-alias.test.ts, migration/backfill/repair: src/commands/doctor-auth-flat-profiles.test.ts, migration/backfill/repair: src/commands/doctor-auth-flat-profiles.ts, migration/backfill/repair: src/commands/doctor-auth-migration-receipts.ts, migration/backfill/repair: src/commands/doctor.fast-path-mocks.ts, migration/backfill/repair: src/commands/doctor/repair-sequencing.test.ts, and 11 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge-risk options

Maintainer options:

  1. Accept the verified canonical migration (recommended)
    Merge after the Doctor/auth owner confirms that verified archival and the documented openai-codex to openai conversion are the intended upgrade contract.
  2. Pause for an additional legacy fixture
    Keep this PR open if maintainers need a fixture for a known production legacy layout not covered by the current receipt, sidecar, and alias tests.

Technical review

Best possible solution:

Keep one receipt-backed migration owner for all retired auth-file shapes, preserve the current sidecar-before-import ordering, and merge only after the Doctor/auth owner accepts the documented upgrade behavior and archive semantics.

Do we have a high-confidence way to reproduce the issue?

Yes—current main source shows separate auth-file repair paths in the command and health flows, while the branch routes those shapes through the receipt-backed migration owner; this review did not execute a local migration because the checkout is read-only.

Is this the best way to solve the issue?

Yes. Centralizing normalization, verification, receipt writes, and archival in the existing SQLite migration owner is preferable to retaining parallel rewriters with different recovery semantics.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against a84302cd73aa.

Labels

Label changes:

  • add P2: The change affects upgrade-time credential recovery but has bounded scope and strong focused proof.
  • add merge-risk: 🚨 compatibility: Merging changes how existing legacy auth files and config credentials are migrated, verified, and archived during upgrades.
  • add merge-risk: 🚨 auth-provider: The migration canonicalizes persisted legacy openai-codex profiles and references to the openai provider.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes a real isolated Linux openclaw doctor --fix --non-interactive run twice against a legacy OAuth/API-key fixture, showing canonical provider/profile output, preserved original archive bytes, a completed receipt, source removal, and idempotence.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes a real isolated Linux openclaw doctor --fix --non-interactive run twice against a legacy OAuth/API-key fixture, showing canonical provider/profile output, preserved original archive bytes, a completed receipt, source removal, and idempotence.

Label justifications:

  • P2: The change affects upgrade-time credential recovery but has bounded scope and strong focused proof.
  • merge-risk: 🚨 compatibility: Merging changes how existing legacy auth files and config credentials are migrated, verified, and archived during upgrades.
  • merge-risk: 🚨 auth-provider: The migration canonicalizes persisted legacy openai-codex profiles and references to the openai provider.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes a real isolated Linux openclaw doctor --fix --non-interactive run twice against a legacy OAuth/API-key fixture, showing canonical provider/profile output, preserved original archive bytes, a completed receipt, source removal, and idempotence.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes a real isolated Linux openclaw doctor --fix --non-interactive run twice against a legacy OAuth/API-key fixture, showing canonical provider/profile output, preserved original archive bytes, a completed receipt, source removal, and idempotence.

Evidence

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the current-main migration and config-repair path identified by blame and authored this consolidation branch. (role: feature owner and recent area contributor; confidence: high; commits: 475ea69f2c35, 2747d785d243; files: src/commands/doctor-auth-flat-profiles.ts, src/commands/doctor/repair-sequencing.ts, src/flows/doctor-health-contributions.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 3777f00 into main Aug 1, 2026
196 of 210 checks passed
@steipete
steipete deleted the codex/goal100k-doctor-auth-owner-0801-2d45 branch August 1, 2026 11:51
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Aug 1, 2026
* origin/main:
  refactor(doctor): unify legacy auth migration ownership (openclaw#117361)
  fix(plugins): surface actionable doctor warnings (openclaw#117357)
  fix(ci): use corrected Kova release evaluator (openclaw#116920)
  fix(ci): stabilize release validation assertions (openclaw#117377)
  refactor(memory): use sqlite transcript identities (openclaw#117334)
  fix(plugins): require tracked owners for targeted updates (openclaw#117333)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* origin/main:
  refactor(doctor): unify legacy auth migration ownership (openclaw#117361)
  fix(plugins): surface actionable doctor warnings (openclaw#117357)
  fix(ci): use corrected Kova release evaluator (openclaw#116920)
  fix(ci): stabilize release validation assertions (openclaw#117377)
  refactor(memory): use sqlite transcript identities (openclaw#117334)
  fix(plugins): require tracked owners for targeted updates (openclaw#117333)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant