Skip to content

fix: migrate client credentials automatically before startup - #178998

Merged
fuller-stack-dev merged 14 commits into
mainfrom
fix/automatic-client-credential-startup
Oct 21, 2026
Merged

fuller-stack-dev merged 14 commits into
mainfrom
fix/automatic-client-credential-startup

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes Mac app, Gateway, and node startup requiring manual credential repair after an update leaves migration pending or the filesystem renumbers the same database.

User Impact

Supported upgrades migrate credentials and approvals automatically, preserving existing keys, pairing tokens, and policy without a Doctor command, prompt, or re-pairing. Malformed required input and a different database generation preserve existing credentials for recovery.

Why This Change Was Made

Startup completes config and state admission before credential writes, then uses the existing migration, backup, and maintenance owners. The Mac app prepares through its matching bundled runtime before starting credential consumers. Rollback restores the previous binding; interrupted completion can resume on the same committed source.

Database porting retains each shared root's local credential companion through forward, reverse, resumed, and rolled-back transitions. Local credentials stay in SQLite and remain included in backups. Preparation does not manage services.

Evidence

The published head is a9b80488a4e89e5ff3f4e7f27e34f60efa7f498b, integrated with canonical main ac7109377409762eaa5928989dd0295a99975f74. All 62 authored paths retain the exact blobs and modes from reviewed correction df709e0a253d4ea6409a617b8b865c3767662f8c. Current-head CI passed with 110 successful jobs, 19 planned skips, and zero failures. Both required gates passed. Its executed test merge was 43b5c18b4e96158d77a3e6c4640232409eff5385, from main fc3a42a7eb87a906597187f18db62201020d275b and this head. GitHub merged the PR as 5f40d22a366da865a83658698ecfb4bed5f965bb at 09:36:18 UTC on October 21, 2026. All planned typechecks and all three PostgreSQL conformance jobs passed, including the corrected credential-owner typing and canonical discovery cases. The latest corrections type an existing socket fixture, use canonical private profiles in PostgreSQL discovery and deferred legacy-profile migration tests, and await worker retirement before test-directory cleanup. Existing credentials, anchors, directory inventories, schema deferral, authorization, and stable-reference assertions remain covered.

  • Local real-PostgreSQL and credential validation passed 57 cases on the preceding integrated source. After adding stronger anchor-directory inventories, both affected discovery cases passed again. All four cases affected by the canonical integration passed on c52, including discovery and backend reconnect.
  • The deferred legacy-profile migration test passed all seven cases on Node and the repository-pinned Bun after correcting its path from an auxiliary store to the canonical profile store. The path-only correction also passed all 13 schema and credential-owner cases. No production guard was relaxed.
  • Independent API reviews found no actionable P0/P1 defect. All three corrected test files received complete audits; no assertions were weakened or cases removed. Independent credential-owner validation passed five clauses, 93 actions, and nine filesystem checks.
  • Native Mac composition passed on published predecessor bd61ac44806a291b2d59901317dfef7997e8d8b0: pending migration admitted app startup, remount reconciliation retained the identity/private key/token, and retry/relaunch passed.
  • Published-driver upgrade proof passed from stable 2026.10.5 to the exact bd61 package. The update finished, readiness returned 200, the durable message/session survived, and incognito history was cleared. The package SHA-256 was verified. This does not prove authenticated model inference.
  • The same bd61 run explicitly passed PostgreSQL multi-root forward/resume/rollback, global credential continuity, public updater rollback, and standalone Doctor migration. These results remain bound to bd61; the current candidate includes later canonical changes.

The broader bd61 CI run completed with failures, including unresolved inference deadlines, saved-input replay, startup registry locking, and startup-corpus timeout attribution. These results are not labeled inherited or fixed. A focused Linux Testbox allocation queued and was stopped before any test ran.

The focused channel-switch diagnostic reproduced a post-plugin Doctor capture-generation failure during package-to-git-dev switching. The core update returned ok, the run recorded succeeded, and runtime identity matched. Its plugin maintenance warning failed the lane's strict status assertion. The fixture intentionally omits the native filesystem helper to test fallback. The complete lane artifact retains the actual failure; stable return was not reached.

Isolated owner-level comparisons on older canonical 8792e3a68a7ca34f31163fe562dc601292a575ab and the published a9 head both accepted consecutive Doctor intervals with no intervening open. On both revisions, real updater ledger writes after an accepted first receipt reproduced the second-interval capture refusal while preserving credentials. A separate baseline read-only reopen also reproduced the error. These establish pre-existing mechanisms, not the full Docker cause. Result collection omits the first auxiliary receipt, and ledger key reuse overwrites its diagnostic; the retained log therefore cannot identify its acceptance or the mismatched expected generation. No capture-warning repair is claimed here.

The raw red/green videos below identify predecessor ac5a1367fbcf8831fdca01cc8463bae826ac082d. They show original startup refusal and packaged recovery after the recorded device number changes; they do not represent the newer candidate. Independent source-blind validation of that package passed five cases and 102 checks, including wrong-generation preservation and revoked-token absence at the client transmission boundary.

Red baseline video · Green packaged video · Behavior contract · Independent report · Capture manifest · Artifact manifest

The videos render recorded terminal output with idle gaps shortened. They are not native Mac screen captures. Artifact links expire October 28, 2026 UTC.

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review October 21, 2026 03:52
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: a9b80488a4e89e5ff3f4e7f27e34f60efa7f498b
  • Maintainer: @fuller-stack-dev
  • Repository role: maintain

These security sensitive changes were made:

  • src/infra/client-credential-migration-data.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/infra/client-credential-migration.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/infra/client-credential-paths.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/infra/client-credential-readiness.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: macos App: macos cli CLI command changes scripts Repository scripts commands Command implementations size: XL labels Oct 21, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR automatically prepares client credentials through Doctor before macOS app, Gateway, and node startup.

Example: A macOS profile has pending credential migration after updating from 2026.10.5.

  • Before: The app exits and asks the user to run openclaw doctor --fix.
  • After: Startup migrates supported credentials automatically while preserving existing keys and pairing tokens.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, coherent repair with recorded production-entry-point and upgrade evidence, resolved prior findings, and no actionable introduced defect.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): Recorded predecessor proof covers packaged startup recovery, native app IPC admission, stable upgrade continuity, different-generation rejection, and revoked-token absence before client transmission; source comparison supports reuse for the reviewed behavior, while local media and artifact inspection was infrastructure-blocked.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An updated installation can refuse startup until the user manually repairs pending or stale client credentials.
Reason: Automatic recovery has clear user value, retains established migration ownership, and has maintainer-authored direction.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a current startup failure; both prior findings are resolved, no actionable introduced defect was found, and exact-head CI remains pending.

Priority: P0
Reviewed head: a9b80488a4e89e5ff3f4e7f27e34f60efa7f498b

Before merge

None.

Findings

None.

Agent review details

How this fits together

Startup admission validates the selected configuration and database, delegates credential migration to Doctor’s existing maintenance owners, and then admits native, Gateway, and node credential consumers.

flowchart TD
A[App Gateway or node startup] --> B[Configuration and state admission]
B --> C[Credential readiness]
C --> D[Doctor maintenance and backup]
D --> E[Existing migration owners]
E --> F[Local credential SQLite store]
F --> G[Credential consumers]
Loading

Technical review

Best possible solution:

Recover supported credential migrations inline during startup through Doctor while preserving keys, tokens, approval policy, and rollback bindings.

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

Current-main readiness gates and the app’s terminal-repair alert establish the failure path; the PR also records a packaged baseline reproduction, but this read-only review ran no target code.

Is this the best way to solve the issue?

The smallest complete fix delegates startup repair to Doctor and updates receipt, promotion, and port consumers together so credential ownership stays consistent.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1892041df9f4.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current-main startup boundary: Current main checks identity and approval readiness without automatic credential preparation; the PR replaces that node entry point with the shared preparation operation. (src/node-host/startup-state-readiness.ts:4, 1892041df9f4)
  • Existing migration ownership retained: The preparation operation validates required legacy inputs, acquires Doctor maintenance with root:null, and invokes existing schema, identity, auth, and approval migration owners. (src/commands/startup-client-credentials.ts:141, a9b80488a4e8)
  • Prior findings resolved: Setup promotion now accepts verified empty bootstrap provenance while rejecting material-bearing stages; the restore regression expects the enriched PostgreSQL receipt. (src/wizard/setup.migration-promotion.ts:475, a9b80488a4e8)
  • Recorded behavior and upgrade evidence: The PR records native-app migration/remount success and an installed 2026.10.5 upgrade with readiness and durable-session preservation on bd61. The affected startup, credential migration, and native-app production files are unchanged between bd61 and the reviewed head. (apps/macos/Tests/OpenClawIPCTests/ClientCredentialStartupCompositionTests.swift:23, a9b80488a4e8)
  • Authority evidence continuity: The body records wrong-generation preservation and revoked-token absence at the client transmission boundary on ac5a. Comparison shows the subsequent migration changes select the canonical root’s credential companion; auth import and consumed-claim logic remain unchanged. (src/infra/client-credential-migration.ts:279, a9b80488a4e8)
  • Artifact inspection infrastructure limit: The prepared manifest reports “ffprobe failed: spawnSync ffprobe ENOENT”; browser fallback could not access the video, and artifact downloads were blocked at productionresultssa8.blob.core.windows.net. Recorded proof remains attributed to its published predecessors; these inspection limits are not contributor defects. (a9b80488a4e8)

PR surface

Source +1040, Tests +2704, Docs +10, Other +37. Total +3791 across 62 files. Added test files: 6.

View PR surface stats
Area Files Added Removed Net
Source 25 1268 228 +1040
Tests 32 3118 414 +2704
Docs 3 28 18 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 2 48 11 +37
Total 62 4462 671 +3791

Review metrics

Metric Value Why it matters
Production versus test growth Production +1268/-228; tests and test support +3166/-425 Growth covers startup orchestration, receipt lifecycle and root ownership, with distinct migration, rollback, rejection, native composition, and portability coverage.
New CLI option 1: doctor --client-credentials The bundled app uses the narrow preparation operation; it requires repair and noninteractive mode and optionally returns JSON.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P0: The affected macOS upgrade path exits before useful startup and requires terminal-based Doctor recovery; automatic preparation removes that nontechnical-user blocker.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-21T04:09:37.514Z sha 6406c75 :: needs real behavior proof before merge. :: [P1] Update setup promotion for canonical bootstrap receipts | [P2] Update the restore regression for enriched bootstrap provenance

Reviewed October 21, 2026, 5:31 AM ET / 09:31 UTC (Revision 2).

Baseline-Refresh: 713055cd239a7fa1866b9704cf7eb8d9392b0f64
Baseline-Refresh: a7bde44efc3c4776206898acad3fb1515c3149e7
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Oct 21, 2026
Baseline-Refresh: 8aee9dfc97eaabc938c9d3a1e78347f1101ae34c
Baseline-Refresh: 3af9c2d6b0e680c91a3f223d74e1c3067cfd3556
@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 21, 2026
@fuller-stack-dev
fuller-stack-dev merged commit 5f40d22 into main Oct 21, 2026
225 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the fix/automatic-client-credential-startup branch October 21, 2026 09:36
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 22, 2026
…w#178998)

* fix: migrate client credentials automatically before startup

* fix(credentials): preserve startup admission and bootstrap ownership

* fix: preserve credential ownership across state migrations

* test(credentials): type the retained socket fixture

* test(state): use canonical PostgreSQL discovery fixtures

* test(state): use canonical deferred profile migration fixture
steipete added a commit that referenced this pull request Oct 22, 2026
Run normal startup credential custody admission in the existing credential worker before serving, and reuse the admitted receipt postimage instead of reading it again. Preserve migration-required handling, app custody, port rebinding, security checks, and once-per-process admission.

The frozen workload removes 20 credential SQL statements and all 31 credential MAIN statements across boot/restart, with two additional worker requests. Warm SQL/request medians remain 45/11 and warm MAIN remains zero.

Builds on #178998.

Co-authored-by: Jason (Json) <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 23, 2026
…aw#180154)

Run normal startup credential custody admission in the existing credential worker before serving, and reuse the admitted receipt postimage instead of reading it again. Preserve migration-required handling, app custody, port rebinding, security checks, and once-per-process admission.

The frozen workload removes 20 credential SQL statements and all 31 credential MAIN statements across boot/restart, with two additional worker requests. Warm SQL/request medians remain 45/11 and warm MAIN remains zero.

Builds on openclaw#178998.

Co-authored-by: Jason (Json) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts security-sensitive-changed 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