Skip to content

fix: await native credential migration observations - #190873

Merged
roboclaw-bot merged 65 commits into
mainfrom
roboclaw/doctor-native-credentials
Nov 2, 2026
Merged

roboclaw-bot merged 65 commits into
mainfrom
roboclaw/doctor-native-credentials

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Doctor's native credential imports and identity repair synchronously inspect database generations around native writes. These reads can block signal handling even though the caller is asynchronous.

Await those observations outside transactions while retaining the existing native custody. One generator supplies the native transaction/admission policy to the synchronous SDK driver and the awaited Doctor adapter. Device auth and identity import/repair consume that adapter. Main's companion/PostgreSQL migration contract is preserved; unused later-stage preparation and inherited CI/process/backup changes are removed. The wrapper inventory includes the seven direct dependencies introduced by the awaited reader import.

Validation: the stable Doctor token-import entry point fails on main with three synchronous generation-reader calls and passes with this change, preserving token and source bytes. Four named credential owner files pass (61 tests, four PostgreSQL-only skips locally), including public capture/Doctor/rollback, cancellation and authority loss. Six existing affected state-migration files pass (95 tests across two shards,55.16s). Scoped format/lint/diff checks pass on all12 changed TypeScript files. Exact-head PR CI is required before landing. Explicit Node replay of the same ten named files also passes (156 tests, four PostgreSQL-only skips,226.02s). The existing wrapper source-closure tests pass4/4, and its focused eager inventory contract passes1/1. Canonical independent P0–P2 autoreview is clean across all production/test changes and the seven required wrapper source-inventory records. Test allocation151LF; no scalar change.

Native macOS large-family/latest-stable installation qualification is not claimed by local focused tests; broad and PostgreSQL execution belongs to exact-head PR CI on this production Team host. No Gateway or live state operation is part of this PR.

Related: #178359, #187900, #185879. Preceding split stages #190870 and #190872 are landed. Not yet released.

Thanks to chrislro's reported stack.

roboclaw-bot and others added 19 commits November 2, 2026 01:53
Add Doctor snapshot cancellation and capacity regressions for CI baseline proof before completing the async owner cutover.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>

Co-authored-by: steipete <[email protected]>
Await snapshot preparation and cleanup across Doctor inspection and repair planning, preserve original-path admission, and reject snapshots that exceed measured cache capacity. Retain synchronous public and transaction authority contracts.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>

Co-authored-by: steipete <[email protected]>
Bind task-worker cancellation to snapshot custody, retain the updater identity export, and repair async consumer fixtures and wrapper source closure. Keep the lease SQL kernel at its existing lifecycle owner.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Preserve per-run cancellation semantics in worker handler fixtures after adding the task-owned abort signal.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
…ries

Keep inaccessible state roots in the diagnostic result, and update source-isolation, lease-poll, and PostgreSQL transport fixtures to observe the actual async owners. Complete task control fixture migration.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Integrate tested main 1347e90 to resolve the named numeric-parser CI contract mismatch from #189993. Preserve specific ExpectedCliError diagnostics and refused dispatch in capability fixtures. Correct the generated IPC preload newline found by review; its cooked script passes node --check.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Apply the repository formatter to the two exact files reported by main-tier CI.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Await session and legacy-auth images, private engine reads, and fresh recovery inventories through the existing cancellable snapshot owner. Preserve writer and SDK contracts and reassert effect authority after awaited reads.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Use the gateway retention role explicitly in idle coverage, await the authoritative target and presented route pane, and retain failed restart diagnostics without relaxing its assertions.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Retain the existing native custody across asynchronous generation reads before and after synchronous migration writes. Prepare Doctor device credential imports through the same async owner, while preserving the released synchronous SDK driver.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 2, 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.

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review November 2, 2026 04:37
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 2, 2026
Integrate main to resolve CLI fixture and canonical locale conflicts. Retain
the Cron backup manifest owner and await the existing asynchronous schema gate.

Wait for hook notice enqueue, browser provider entry, and identity authorization
completion before checking their results; retain assertions and test budgets.
Add bounded failure diagnostics for early child termination.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR makes Doctor await credential-migration generation observations while sharing mutation policy with the synchronous credential owner.

Example: Doctor imports a retained node identity into ~/.openclaw/client/credentials.sqlite during captured maintenance.

  • Before: Generation inspection waits synchronously and prevents JavaScript signal handling.
  • After: The converted path awaits isolated inspection before running the synchronous native transaction.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The direction is valuable, but the new authority regression fails, wrapper closure is incomplete, and current-stage runtime and stable-upgrade compatibility evidence is outstanding.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Doctor can stop responding to cancellation while synchronous database-generation inspection waits for a child process.
Reason: The maintainer-authored direction addresses a documented recovery-workflow problem while retaining the released synchronous contract; this stage covers only credential observations.

Merge readiness

⛔ Blocked before merge - 7 items remain

Keep this useful maintainer-authored follow-up open; the introduced diff has a failing authority-loss test, an incomplete wrapper dependency inventory, and unused companion orchestration.

Priority: P1
Reviewed head: b0456a0eee9e9997763a0bad59c73c6c9813af03

Before merge

  • Add real behavior proof - Authority-chain proof required: demonstrate an authorized Doctor credential import through the converted production owner and show that losing maintenance custody during observation prevents credential I/O; also show cancellation settles owned inspection cleanup, with private paths and credentials redacted. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Bind the authority-loss fixture to a guard the migration actually calls (P2) - In the 'lose authority before mutation' row, setting current=false only affects the callback passed as withCapture's assertDatabaseAccess argument. The temporary database has no persisted owner, so assertPersistedStateDatabaseAccessAllowed returns on ENOENT without calling that callback, while assertOwnerCurrent remains a no-op. The migration therefore executes and resolves, matching the exact-head CI failure at line 183. Inject loss through the maintenance owner's assertOwnerCurrent or capture.assertCurrent and retain the assertion that no row is written.
  • Include the new runtime dependencies in the wrapper inventory (P2) - This dynamic import makes update-candidate-state.inspection.ts and its inspection dependencies reachable from runtime entrypoints covered by scripts/pr-lib/wrapper-components.txt, but the inventory is unchanged. Exact-head pr-wrapper-source-closure.test.ts reports seven missing files and fails checks-node-compact-small-1. Update the inventory through its owner so the frozen wrapper source closure includes the newly reachable modules.
  • Remove companion orchestration that has no production consumer (P2) - The new recursive companions driver, retained companion-source list, and prepared-companion branch are reached through the companions option only in the added test. None of the converted production credential callers supplies that option, so this adds another migration execution path without completing a caller cutover. This conflicts with the repository's smallest-complete-fix and test-only-machinery rules. Keep the shared single-source sync/async driver and defer companion orchestration until a real consumer moves with it.
  • Resolve security review attention item - No concrete authorization bypass was established, but the new credential waits require valid final-effect authority evidence.
  • Resolve merge risk - Before merge, the PR owner must establish that losing Doctor maintenance authority during an awaited observation prevents the subsequent credential write.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Bind the authority-loss fixture to a guard the migration actually calls — src/infra/update-doctor-migration-attribution.test.ts:157-158
  • [P2] Include the new runtime dependencies in the wrapper inventory — src/infra/update-doctor-migration-attribution.ts:283-284
  • [P2] Remove companion orchestration that has no production consumer — src/infra/update-doctor-migration-attribution.ts:321-327

Tests

  • Low-value test src/infra/update-doctor-migration-attribution.test.ts: The new companion-observation group exercises an options path supplied by no production caller; remove it with that unused orchestration.
  • Missing end-to-end proof: No supplied execution demonstrates the converted Doctor credential-import path, cancellation cleanup, and rejection after maintenance authority is lost; red-on-base/green-on-head evidence is also absent.
Agent review details

How this fits together

Doctor imports legacy identities and tokens through the local credential owner; migration attribution observes database generations and records which writes belong to the update's recovery capture.

flowchart TD
  A[Doctor repair] --> B[Credential custody owner]
  B --> C[Migration attribution]
  C --> D[Isolated generation inspection]
  C --> E[Synchronous native transaction]
  E --> F[Local credential database]
  C --> G[Update recovery receipt]
Loading

Technical review

Best possible solution:

Keep the shared synchronous mutation owner, await its required observations, repair the authority fixture and wrapper inventory, and remove companion orchestration without a production consumer.

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

Current main synchronously invokes generation inspection around native credential transactions; the reported stack samples support the broader blocking mechanism, but this review ran no target code.

Is this the best way to solve the issue?

Sharing one native mutation policy between synchronous and asynchronous drivers is appropriate, but unused companion orchestration exceeds the smallest complete credential cutover.

Full review comments:

  • [P2] Bind the authority-loss fixture to a guard the migration actually calls — src/infra/update-doctor-migration-attribution.test.ts:157-158
    In the 'lose authority before mutation' row, setting current=false only affects the callback passed as withCapture's assertDatabaseAccess argument. The temporary database has no persisted owner, so assertPersistedStateDatabaseAccessAllowed returns on ENOENT without calling that callback, while assertOwnerCurrent remains a no-op. The migration therefore executes and resolves, matching the exact-head CI failure at line 183. Inject loss through the maintenance owner's assertOwnerCurrent or capture.assertCurrent and retain the assertion that no row is written.
    Confidence: 0.99
  • [P2] Include the new runtime dependencies in the wrapper inventory — src/infra/update-doctor-migration-attribution.ts:283-284
    This dynamic import makes update-candidate-state.inspection.ts and its inspection dependencies reachable from runtime entrypoints covered by scripts/pr-lib/wrapper-components.txt, but the inventory is unchanged. Exact-head pr-wrapper-source-closure.test.ts reports seven missing files and fails checks-node-compact-small-1. Update the inventory through its owner so the frozen wrapper source closure includes the newly reachable modules.
    Confidence: 0.99
  • [P2] Remove companion orchestration that has no production consumer — src/infra/update-doctor-migration-attribution.ts:321-327
    The new recursive companions driver, retained companion-source list, and prepared-companion branch are reached through the companions option only in the added test. None of the converted production credential callers supplies that option, so this adds another migration execution path without completing a caller cutover. This conflicts with the repository's smallest-complete-fix and test-only-machinery rules. Keep the shared single-source sync/async driver and defer companion orchestration until a real consumer moves with it.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Complete the focused repair and authority validation (recommended)
    The PR owner fixes the listed defects and demonstrates that current maintenance custody gates credential writes after observation waits.
  2. Pause this dependent stage
    Keep the branch open until its prerequisite and credential-boundary validation are ready.

Provenance checked

  • Credential custody and synchronous compatibility keeps the original intent (8f62210: Local credential cutover established exclusive custody, exact receipts, and unchanged approval and effect-time authority.)
  • Generation admission and empty-reader equivalence keeps the original intent (237fdc6: Read-only WAL coordination changes must not invalidate unchanged captured contents, while real writes still refuse attribution.)
  • Physical path attribution keeps the original intent (cf39400: Capture and migration attribution must use the same physical SQLite key through state-directory aliases.)
  • Legacy identity and auth import keeps the original intent (05ade6d: Doctor imports primary, node, and share-extension identities through the credential owner while preserving keys and consumed-source claims.)
  • Isolated generation inspection keeps the original intent (ad1b598: Candidate-side generation inspection supports older updater fingerprints without weakening changed-source refusal.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete authorization bypass was established, but the new credential waits require valid final-effect authority evidence.

Evidence

What I checked:

Likely related people:

  • Jason (Json): Raw commit 5f40d22 adds src/infra/state-migrations.device-auth.ts:143 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 5f40d22a366d; files: src/infra/state-migrations.device-auth.ts)

PR surface

Source +318, Tests +182, Other +1. Total +501 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 7 460 142 +318
Tests 2 192 10 +182
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 10 653 152 +501

Labels

Label changes:

  • add P1: The change addresses signal-blocking Doctor inspection work in a recovery workflow with documented user stalls.
  • add merge-risk: 🚨 security-boundary: New waits precede credential mutations, and the added authority-loss case currently fails without exercising its intended revocation guard.
  • add merge-risk: 🚨 automation: The introduced dynamic import violates the PR wrapper's runtime-source closure inventory and fails its exact-head guard.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P1: The change addresses signal-blocking Doctor inspection work in a recovery workflow with documented user stalls.
  • merge-risk: 🚨 security-boundary: New waits precede credential mutations, and the added authority-loss case currently fails without exercising its intended revocation guard.
  • merge-risk: 🚨 automation: The introduced dynamic import violates the PR wrapper's runtime-source closure inventory and fails its exact-head guard.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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.

Reviewed November 1, 2026, 11:55 PM ET / November 2, 2026, 04:55 UTC.

roboclaw-bot and others added 3 commits November 2, 2026 05:06
Integrate the reviewed core conflict repair and retain canonical backup and
live-destination guards. Update consumer fixtures to observe asynchronous
producers and persisted shared-auth outcomes, with current source formatting.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Keep the existing close and no-backfill checks using logger creation metadata
instead of independently buffered file offsets. Millisecond ties remain
explicitly ambiguous; native lease lifetime assertions retain their own proof.
Add bounded diagnostics for the unresolved config admission refusal and mark
the existing platform partial mocks at their owning isolation boundaries.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Retain the selected database access guard before native effects and express
the existing receiverless credential callback contract. Complete the native
wrapper dependency closure for asynchronous generation observations.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes commands Command implementations agents Agent runtime and tooling extensions: qa-lab size: XL and removed size: L labels Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 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: 734cf49f1fff11cd7f22fa93028058f91f283243
  • Maintainer: @roboclaw-bot
  • Repository role: maintain

These security sensitive changes were made:

  • src/infra/client-credential-store.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.

Merge main and keep this stage limited to session-independent local credential
imports and identity repair. Retain the synchronous native driver and defer
unused companion preparation to its actual consumer stage.

Co-authored-by: steipete <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes commands Command implementations agents Agent runtime and tooling extensions: qa-lab size: XL labels Nov 2, 2026
Keep the seven direct inspection dependencies in the existing PR wrapper
source inventory after awaited native attribution imports that reader.

Co-authored-by: steipete <[email protected]>
@roboclaw-bot
roboclaw-bot merged commit 384e6a6 into main Nov 2, 2026
149 of 150 checks passed
@roboclaw-bot
roboclaw-bot deleted the roboclaw/doctor-native-credentials branch November 2, 2026 17:44
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
Await native credential generation observations outside transactions while retaining the existing exclusive custody and native writes. Route Doctor device-auth/device-identity import and canonical identity repair through that adapter; retain one policy for the synchronous SDK driver.

Keep this split limited to native credential observations and direct tests. Preserve main's companion/PostgreSQL contract and remove inherited later-stage/CI changes and unused future preparation. The stable Doctor token-import regression is red on main and green with the fix; test allocation151 net LF.

Related: openclaw#178359, openclaw#187900. Not yet released.

Co-authored-by: steipete <[email protected]>
Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. scripts Repository scripts security-sensitive-changed size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant