Skip to content

fix: let Doctor check device identities without locking the credential store - #206513

Merged
fuller-stack-dev merged 2 commits into
openclaw:mainfrom
fuller-stack-dev:fix/doctor-device-identity-read-only-inspection
Nov 27, 2026
Merged

fuller-stack-dev merged 2 commits into
openclaw:mainfrom
fuller-stack-dev:fix/doctor-device-identity-read-only-inspection

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Related: #204775

What Problem This Solves

Every openclaw doctor --fix checks whether the stored device identities are damaged. That check is meant to be read-only, but it opened the local credential store for writing three times, switched it to exclusive locking and began a write transaction each time. On a healthy install it changed nothing, yet it took the store's write lock. When another client held that lock, each read waited the 5 s busy timeout and then reported "no damaged identity", so Doctor could skip a repair it should have made.

User Impact

The damaged-identity check no longer locks the credential store or waits on another client's write. A damaged identity is detected while a write is open, and Doctor still replaces it as before. Commands that only load an existing device identity (loadDeviceIdentityIfPresent, used by the CLI, node host, TUI and plugin SDK Gateway runtime) read the same way. Nothing changes in what any repair writes, and there is no config, schema or permission change.

Why This Change Was Made

readStoredDeviceIdentityReadOnly asked credential custody for readOnly, but custody still used a read-write connection, PRAGMA locking_mode=EXCLUSIVE and BEGIN IMMEDIATE. The custody owner now has an inspect mode: a read-only connection and a deferred read transaction, with the same version, schema, integrity and receipt checks (admitClientCredentialStore in read-only mode writes nothing). The store uses DELETE journal mode, so a read-only open creates no files. If a -journal file exists, a hot rollback may be needed, so inspection falls back to the existing custody path, which can roll it back. Gateway worker reads keep their current custody.

This is the first read-first change from the config-flow plan in #204775. The other pieces are not in this PR (see "What is not done"), so doctor.pending.config-flow still answers work check=default.

Evidence

Tested commit: ed9b9df03ca (pack built from it). The pushed head merges current main into it. Nothing in the merged range touches the credential store, device identity or Doctor. After the merge, the focused tests were rerun and pass.

Root cause, unit level (red on unmodified main, green on head). New case in src/infra/state-migrations.device-identity.test.ts: it seeds an invalid primary identity, holds the store's write lock from a second connection (BEGIN IMMEDIATE), runs detection, and checks that the store file is unchanged.

  • main 67145de5d94: the case fails after 16.1 s. Detection waited the busy timeout three times and returned hasInvalidCanonical: false.
  • Head: it passes in 11 ms with hasInvalidCanonical: true. Without the competing lock, the existing case "replaces an invalid canonical row without legacy JSON only under Doctor authority" passes on both, which rules out other causes.

Real CLI cells. Linux, systemd user Gateway, npm install of a locally packed build. Unpublished versions: 2026.11.27 is main 67145de5d94, 2026.11.28 is the PR parent 33fa6a84cec, 2026.11.29 is the head. Config: Telegram plus the bundled memory-core, browser, active-memory and llm-task plugins. Two healthy doctor --fix runs ran under strace -f with an io trace of every write-intent fs call and every node:sqlite open, write and BEGIN IMMEDIATE, limited to the doctor.config-flow span.

doctor.config-flow, healthy run main (doctor1 / doctor2) head (doctor1 / doctor2)
client/credentials.sqlite read-write opens 4 / 4 1 / 1
client/credentials.sqlite BEGIN IMMEDIATE 4 / 4 1 / 1
client/credentials.sqlite read-only opens 0 / 0 3 / 3
state/openclaw.sqlite rw opens / BEGIN IMMEDIATE / row writes 3 / 14 / 13 3 / 14 / 13 (unchanged, not in scope)
agent database rw opens / BEGIN IMMEDIATE 2 / 3 2 / 3 (unchanged)
doctor.pending.config-flow work check=default work check=default

The one remaining credential-store read-write open on head comes from the state schema repair's credential custody (prepareClientCredentialMigrationCustody), not from detection. Store snapshots after a healthy run change the same rows on both builds (Gateway boot rows, agent_databases.last_seen_at, leases), and credentials.sqlite is byte-identical on both.

Guards. Same fixture with Telegram disabled and /readyz probed every 250 ms, PR parent vs head. While the Gateway served, the cell seeded an invalid primary identity row and a retired node-device.json.

  • Both builds: doctorwork printed "Replaced invalid primary device identity in SQLite." and "Retained legacy identity JSON is already consumed". The primary row afterwards had valid key material. doctorclean and the healthy runs made no replacement.
  • Outage (/readyz not ready): parent 27.0, 23.2, 26.5 and 29.0 s; head 24.7, 24.9, 27.7 and 28.5 s. This is within noise on this host. The legacy-state step took 1.7 to 2.3 s on parent and 1.8 to 2.1 s on head.

Red (main 67145de5d94, raw cell logs replayed):

red-base.mp4

Green (head ed9b9df03ca plus the parent vs head guard cells):

green-head.mp4
Raw red evidence (main 67145de)
=== RED: unmodified main 67145de5d94
cell measure-base: Linux, systemd user Gateway, npm install of pack 2026.11.27 67145de5d94; telegram channel + memory-core, browser, active-memory, llm-task

---- doctor1: OPENCLAW_GATEWAY_STARTUP_TRACE=1 openclaw doctor --fix --non-interactive --yes (healthy install, strace + io trace)
  trace: doctor.pending.config-flow 0.0ms pending=work check=default
  trace: doctor.config-flow 9073.8ms
  config-flow window, write-intent opens, write locks and row writes per store:
    3 BEGIN IMMEDIATE  ~/.openclaw/agents/main/agent/openclaw-agent.sqlite
    2 rw open          ~/.openclaw/agents/main/agent/openclaw-agent.sqlite
    4 BEGIN IMMEDIATE  ~/.openclaw/client/credentials.sqlite
    4 rw open          ~/.openclaw/client/credentials.sqlite
    1 BEGIN IMMEDIATE  ~/.openclaw/state/openclaw-quarantine.sqlite
    1 rw open          ~/.openclaw/state/openclaw-quarantine.sqlite
   14 BEGIN IMMEDIATE  ~/.openclaw/state/openclaw.sqlite
    1 open r+          ~/.openclaw/state/openclaw.sqlite
   13 row write        ~/.openclaw/state/openclaw.sqlite
    3 rw open          ~/.openclaw/state/openclaw.sqlite
    1 open r+          ~/.openclaw/tmp/openclaw-1001/gateway.state.lock
  credential store callers:
   1 [cli.bootstrap.legacy-state-migrations] store file://~/.openclaw/client/credentials.sqlite?mode=rw :: sqlite-open rw :: openNodeSqliteDatabase < openClientCredentialCustodySteps < openClientCredentialCustodyAsync < prepareClientCredentialMigrationCustody < O
   4 [cli.bootstrap.legacy-state-migrations] store ~/.openclaw/client/credentials.sqlite :: sqlite-lock BEGIN IMMEDIATE :: execute < e.exec < execNativeBegin < beginImmediateTransaction < execTimedTransactionStep < runSqliteTransactionSync
   3 [cli.bootstrap.legacy-state-migrations] store file://~/.openclaw/client/credentials.sqlite?mode=rw :: sqlite-open rw :: openNodeSqliteDatabase < openClientCredentialCustodySteps < openClientCredentialCustody < runClientCredentialOperation < readStoredDeviceI

---- doctor2: OPENCLAW_GATEWAY_STARTUP_TRACE=1 openclaw doctor --fix --non-interactive --yes (healthy install, strace + io trace)
  trace: doctor.pending.config-flow 0.1ms pending=work check=default
  trace: doctor.config-flow 17229.1ms
  config-flow window, write-intent opens, write locks and row writes per store:
    3 BEGIN IMMEDIATE  ~/.openclaw/agents/main/agent/openclaw-agent.sqlite
    2 rw open          ~/.openclaw/agents/main/agent/openclaw-agent.sqlite
    4 BEGIN IMMEDIATE  ~/.openclaw/client/credentials.sqlite
    4 rw open          ~/.openclaw/client/credentials.sqlite
    1 BEGIN IMMEDIATE  ~/.openclaw/state/openclaw-quarantine.sqlite
    1 rw open          ~/.openclaw/state/openclaw-quarantine.sqlite
   14 BEGIN IMMEDIATE  ~/.openclaw/state/openclaw.sqlite
    1 open r+          ~/.openclaw/state/openclaw.sqlite
   13 row write        ~/.openclaw/state/openclaw.sqlite
    3 rw open          ~/.openclaw/state/openclaw.sqlite
    1 open r+          ~/.openclaw/tmp/openclaw-1001/gateway.state.lock
  credential store callers:
   1 [cli.bootstrap.legacy-state-migrations] store file://~/.openclaw/client/credentials.sqlite?mode=rw :: sqlite-open rw :: openNodeSqliteDatabase < openClientCredentialCustodySteps < openClientCredentialCustodyAsync < prepareClientCredentialMigrationCustody < O
   4 [cli.bootstrap.legacy-state-migrations] store ~/.openclaw/client/credentials.sqlite :: sqlite-lock BEGIN IMMEDIATE :: execute < e.exec < execNativeBegin < beginImmediateTransaction < execTimedTransactionStep < runSqliteTransactionSync
   3 [cli.bootstrap.legacy-state-migrations] store file://~/.openclaw/client/credentials.sqlite?mode=rw :: sqlite-open rw :: openNodeSqliteDatabase < openClientCredentialCustodySteps < openClientCredentialCustody < runClientCredentialOperation < readStoredDeviceI

---- unhealthy cell unhealthy-base (pack 2026.11.27 67145de5d94): discord channel and diffs plugin configured, neither installable
ledger deferred-plugin-migration:diffs status=pending started=1795765431572 finished=null reason="The migration owner is unavailable. Install or ena..."
ledger deferred-plugin-migration:discord status=completed started=1795765431572 finished=1795765437062 reason="Not applicable: the plugin owner is unavailable an..."
ledger deferred-plugin-migration:diffs status=pending started=1795765431572 finished=null reason="The migration owner is unavailable. Install or ena..."
ledger deferred-plugin-migration:discord status=completed started=1795765431572 finished=1795765557550 reason="Not applicable: the plugin owner is unavailable an..."
ledger deferred-plugin-migration:diffs status=pending started=1795765431572 finished=null reason="The migration owner is unavailable. Install or ena..."
ledger deferred-plugin-migration:discord status=completed started=1795765431572 finished=1795765711183 reason="Not applicable: the plugin owner is unavailable an..."
ledger deferred-plugin-migration:diffs status=pending started=1795765431572 finished=null reason="The migration owner is unavailable. Install or ena..."
ledger deferred-plugin-migration:discord status=completed started=1795765431572 finished=1795765845290 reason="Not applicable: the plugin owner is unavailable an..."
doctor1: registry requests for the uninstallable plugins: 6 (/@openclaw%2fdiffs, /@openclaw%2fdiscord)
doctor2: registry requests for the uninstallable plugins: 6 (/@openclaw%2fdiffs, /@openclaw%2fdiscord)
doctor3: registry requests for the uninstallable plugins: 6 (/@openclaw%2fdiffs, /@openclaw%2fdiscord)
Raw green and guard evidence (head ed9b9df, parent 33fa6a8)
=== GREEN: head ed9b9df03ca (parent 33fa6a84cec)
cell measure-head: Linux, systemd user Gateway, npm install of pack 2026.11.29 ed9b9df03ca; telegram channel + memory-core, browser, active-memory, llm-task

---- doctor1: OPENCLAW_GATEWAY_STARTUP_TRACE=1 openclaw doctor --fix --non-interactive --yes (healthy install, strace + io trace)
  trace: doctor.pending.config-flow 0.0ms pending=work check=default
  trace: doctor.config-flow 7000.1ms
  config-flow window, write-intent opens, write locks and row writes per store:
    3 BEGIN IMMEDIATE  ~/.openclaw/agents/main/agent/openclaw-agent.sqlite
    2 rw open          ~/.openclaw/agents/main/agent/openclaw-agent.sqlite
    1 BEGIN IMMEDIATE  ~/.openclaw/client/credentials.sqlite
    1 rw open          ~/.openclaw/client/credentials.sqlite
    1 BEGIN IMMEDIATE  ~/.openclaw/state/openclaw-quarantine.sqlite
    1 rw open          ~/.openclaw/state/openclaw-quarantine.sqlite
   14 BEGIN IMMEDIATE  ~/.openclaw/state/openclaw.sqlite
    1 open r+          ~/.openclaw/state/openclaw.sqlite
   13 row write        ~/.openclaw/state/openclaw.sqlite
    3 rw open          ~/.openclaw/state/openclaw.sqlite
  credential store callers:
   1 [cli.bootstrap.legacy-state-migrations] store file://~/.openclaw/client/credentials.sqlite?mode=rw :: sqlite-open rw :: openNodeSqliteDatabase < openClientCredentialCustodySteps < openClientCredentialCustodyAsync < prepareClientCredentialMigrationCustody < O
   1 [cli.bootstrap.legacy-state-migrations] store ~/.openclaw/client/credentials.sqlite :: sqlite-lock BEGIN IMMEDIATE :: execute < e.exec < execNativeBegin < beginImmediateTransaction < execTimedTransactionStep < runSqliteTransactionSync
   3 [cli.bootstrap.legacy-state-migrations] store file://~/.openclaw/client/credentials.sqlite?mode=ro&readonly_shm=1 :: sqlite-open ro :: openNodeSqliteDatabase < openClientCredentialCustodySteps < openClientCredentialCustody < runClientCredentialOperation < re

---- doctor2: OPENCLAW_GATEWAY_STARTUP_TRACE=1 openclaw doctor --fix --non-interactive --yes (healthy install, strace + io trace)
  trace: doctor.pending.config-flow 0.0ms pending=work check=default
  trace: doctor.config-flow 10075.8ms
  config-flow window, write-intent opens, write locks and row writes per store:
    3 BEGIN IMMEDIATE  ~/.openclaw/agents/main/agent/openclaw-agent.sqlite
    2 rw open          ~/.openclaw/agents/main/agent/openclaw-agent.sqlite
    1 BEGIN IMMEDIATE  ~/.openclaw/client/credentials.sqlite
    1 rw open          ~/.openclaw/client/credentials.sqlite
    1 BEGIN IMMEDIATE  ~/.openclaw/state/openclaw-quarantine.sqlite
    1 rw open          ~/.openclaw/state/openclaw-quarantine.sqlite
   14 BEGIN IMMEDIATE  ~/.openclaw/state/openclaw.sqlite
    1 open r+          ~/.openclaw/state/openclaw.sqlite
   13 row write        ~/.openclaw/state/openclaw.sqlite
    3 rw open          ~/.openclaw/state/openclaw.sqlite
    1 open r+          ~/.openclaw/tmp/openclaw-1001/gateway.state.lock
  credential store callers:
   1 [cli.bootstrap.legacy-state-migrations] store file://~/.openclaw/client/credentials.sqlite?mode=rw :: sqlite-open rw :: openNodeSqliteDatabase < openClientCredentialCustodySteps < openClientCredentialCustodyAsync < prepareClientCredentialMigrationCustody < O
   1 [cli.bootstrap.legacy-state-migrations] store ~/.openclaw/client/credentials.sqlite :: sqlite-lock BEGIN IMMEDIATE :: execute < e.exec < execNativeBegin < beginImmediateTransaction < execTimedTransactionStep < runSqliteTransactionSync
   3 [cli.bootstrap.legacy-state-migrations] store file://~/.openclaw/client/credentials.sqlite?mode=ro&readonly_shm=1 :: sqlite-open ro :: openNodeSqliteDatabase < openClientCredentialCustodySteps < openClientCredentialCustody < runClientCredentialOperation < re

---- guard cell guard-parent (pack 2026.11.28 33fa6a84cec (PR parent)): telegram disabled, /readyz every 250 ms, invalid primary identity row + retired node-device.json seeded while serving
  identity primary device=b8ab777eb5a3 key=pem
  node-device.json absent
  seeded: node-device.json 66a7bb3608bd, invalid primary rows 1
  identity primary device=000000000000 key=invalid
  node-device.json present
  identity primary device=04f60521ae06 key=pem
  node-device.json present
  identity primary device=04f60521ae06 key=pem
  node-device.json present
  doctorwork: - Replaced invalid primary device identity in SQLite.
  doctorwork: - Retained legacy identity JSON is already consumed; local credentials remain authoritative.
  doctor1: 0 identity replacements
  doctor2: 0 identity replacements
  doctorclean: 0 identity replacements
  doctor1: OUTAGE (/readyz) 27.0 s, doctor wall 41.6 s
  doctor2: OUTAGE (/readyz) 23.2 s, doctor wall 37.5 s
  doctorwork: OUTAGE (/readyz) 26.5 s, doctor wall 39.8 s
  doctorclean: OUTAGE (/readyz) 29.0 s, doctor wall 43.6 s

---- guard cell guard-head (pack 2026.11.29 ed9b9df03ca (head)): telegram disabled, /readyz every 250 ms, invalid primary identity row + retired node-device.json seeded while serving
  identity primary device=15c6cdc8c369 key=pem
  node-device.json absent
  seeded: node-device.json 655549478210, invalid primary rows 1
  identity primary device=000000000000 key=invalid
  node-device.json present
  identity primary device=7833b076576e key=pem
  node-device.json present
  identity primary device=7833b076576e key=pem
  node-device.json present
  doctorwork: - Replaced invalid primary device identity in SQLite.
  doctorwork: - Retained legacy identity JSON is already consumed; local credentials remain authoritative.
  doctor1: 0 identity replacements
  doctor2: 0 identity replacements
  doctorclean: 0 identity replacements
  doctor1: OUTAGE (/readyz) 24.7 s, doctor wall 39.5 s
  doctor2: OUTAGE (/readyz) 24.9 s, doctor wall 39.1 s
  doctorwork: OUTAGE (/readyz) 27.7 s, doctor wall 42.0 s
  doctorclean: OUTAGE (/readyz) 28.5 s, doctor wall 43.5 s

CI on head 21a0d90ad65. 68 checks pass. One check fails: checks-node-changed-6, in test/e2e/qa-lab/runtime/gateway-provider-review-product-proof.e2e.test.ts ("dispatches the exact acknowledged steer and preserves session and device authority", line 572: expected status: "error" after the device is removed mid-run, got "ok"). This PR does not cause it:

Commands and results

  • node scripts/run-vitest.mjs src/infra/state-migrations.device-identity.test.ts (red on main, green on head, as above). Every test file under src/ that touches the credential store or device identities (156 files, PostgreSQL excluded), run per directory: infra 550 passed, commands 210, cli 78, tui 44, agents 28, state 22, plugin-sdk 1, node-host 2 files, gateway 72 of 73 files. The one gateway failure (server.mentions-committed.test.ts, a 120 s deadline under host load) passes alone on head and on the parent.
  • node scripts/check-changed.mjs --base origin/main: typecheck (core and tests), lint, import cycles and the repository guards all pass. The dead-export scan reports two exports in extensions/nextcloud-talk from main (refactor(nextcloud-talk): separate webhook decoding from queue lifecycle #203172), not from this diff.
  • Session identity ratchet: OK.
  • Autoreview: Codex route (gpt-6.1-sol) at --max-priority P2, branch mode against origin/main. Result: scoped-clean, no P0 to P2 findings.

Files audited: src/infra/state-migrations.device-identity.test.ts, in full. All helpers and imports are used. No case was removed; one was added.

What is not done (config-flow plan, #204775)

Measured on the same main cells. These keep config-flow from none:

  • State schema repair (prepareOpenClawStateDatabaseSchema(…, "doctor")): explicit Doctor repairs the shared schema every time. That is 14 BEGIN IMMEDIATE, the schema lease, the quarantine store opened read-write, and the custody open above. The existing needsOpenClawStateDatabaseSchemaRepair(…, "doctor") predicate does not cover what this repair can change on a current schema. Missing are: permission drift, recorded damage, user_version or content-row drift, legacy tables, the session watch and publication draft migrations, indexes on lazy tables, additive backfills (ACP, cron jobs, delivery queue, subagent runs, operator approvals), and the credential receipt. Two of these have no read-only predicate today (delivery queue compaction, cron job backfill).
  • Agent database (media persistence, cold navigation): maintenance leases, .seal invalidation, the integrity and ensure transactions, and the registry upsert all run unconditionally. Missing read-only predicates: the schema metadata no-op, entry_valid rows, archive verification receipt drift, and planner statistics.
  • Preflight r+ probe: it is kept on purpose. It is the only check that proves the state database can be written (immutable flag, read-only mount, fix(doctor): diagnose immutable state without pending writes #199509). A read-only open cannot prove that, and it writes, locks and leases nothing.
  • Deferred plugin ledger and registry queries (configured plugin that cannot install): every run makes 6 registry requests and rewrites deferred-plugin-migration:discord. In the measured cell its finished_at changed every run. The reopen as pending is load-bearing: file-era session migrations read pending rows from the database during the run and preserve sources while any obligation is pending (deferred-plugin-session-sources.ts). Skipping the reopen would change what those migrations do. Not querying the registry needs a stored "last failed attempt" fact or a retry policy, so both are left for a decision.

Doctor's legacy device identity detection reads each identity through
read-only credential custody, which still opened the local credential store
read-write, switched it to exclusive locking and began an IMMEDIATE
transaction. Three such opens ran on every healthy doctor --fix, and while
another client held the store's write lock each waited the full busy timeout
and then reported no invalid identity.

Inspection now opens the store read-only and reads committed rows in a
deferred transaction with the same schema, integrity and receipt checks. A
hot rollback journal still goes through custody, which can roll it back.
@clawsweeper

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

@github-actions

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: 21a0d90ad65a785d7bf7d34da0b2dd5b89333afb
  • Maintainer: @fuller-stack-dev
  • 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR lets device-identity inspection use read-only SQLite transactions while preserving existing credential repair and journal-recovery custody.

Example: An invalid primary identity is committed in client/credentials.sqlite while another connection holds BEGIN IMMEDIATE without creating a journal.

  • Before: Doctor waits through three busy timeouts and reports hasInvalidCanonical: false.
  • After: Doctor detects hasInvalidCanonical: true without acquiring the write lock.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation appears correct and has meaningful CLI evidence, but required stable-upgrade proof is missing and CI attribution remains unresolved.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Doctor can wait on an unrelated credential writer and silently miss a damaged device identity.
Reason: This is a narrow correction to intended read-only inspection, with direction established by the maintainer-authored PR and its documented place in the Doctor plan.

Merge readiness

✅ Ready for maintainer review

Keep this PR: it addresses a current credential-inspection bug, has maintainer-approved direction, and introduces no definite code defect found in this review.

Reviewed head: 21a0d90ad65a785d7bf7d34da0b2dd5b89333afb

Before merge

None.

Findings

None.

Agent review details

How this fits together

Doctor and synchronous identity loaders call the local credential owner, which admits the credential database, reads identity rows, and returns validated identity material or a storage error; repairs retain the existing write owner.

flowchart TD
  A[Doctor detection] --> C[Device identity reader]
  B[Existing identity loader] --> C
  C --> D[Credential owner]
  D --> E[Read-only inspection]
  D --> F[Existing recovery custody]
  E --> G[Credential SQLite store]
  F --> G
Loading

Technical review

Best possible solution:

Keep inspection inside the existing credential owner, preserve write custody for repairs and journal recovery, and complete the outstanding validation before landing.

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

Current-main source establishes the writable inspection and swallowed lock-error path, supported by the author's reported red-on-main contention test; this review executed no target code.

Is this the best way to solve the issue?

The change repairs the owning credential operation with existing read-only connection and deferred-transaction primitives, preserves admission checks, and adds one distinct contention regression without unnecessary machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Credential inspection versus exclusive custody changes intended behavior with a stated reason (8f62210: The local credential cutover placed readers and writers under one receipt-validated exclusive owner; preparatory exclusive locking dates to 4706053.)
  • Doctor repair admission keeps the original intent (384e6a6: Await migration observations outside native transactions while retaining one generator for synchronous and awaited custody.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 4706053 adds src/infra/client-credential-store.ts:6 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4706053bc398; files: src/infra/client-credential-store.ts)
  • RoboClaw: Raw commit 384e6a6 adds src/infra/client-credential-store.ts:121 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 384e6a6647b1; files: src/infra/client-credential-store.ts)
  • Vincent Koc: Raw commit 410c0dd adds src/infra/client-credential-store.ts:33 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 410c0dda4070; files: src/infra/client-credential-store.ts)

PR surface

Source +30, Tests +24. Total +54 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 45 15 +30
Tests 1 25 1 +24
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 70 16 +54

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide the latest-stable upgrade and Doctor verification described in the proof gap.

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 27, 2026, 3:57 AM ET / 08:57 UTC.

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Inherited CI failure on head 21a0d90ad65

CI run 45967729066, attempt 1. All other required checks passed on this head, including security-fast. Two jobs failed:

  • checks-node-changed-6 has one failing case. It is test/e2e/qa-lab/runtime/gateway-provider-review-product-proof.e2e.test.ts > "dispatches the exact acknowledged steer and preserves session and device authority", line 572: expected status: "error", received "ok". Every other file in the job passed or was skipped.
  • openclaw/ci-gate fails only because of that job. Its classification table marks the job unknown, because scheduled main has no matching job.

This test fails the same way without this PR:

  • main parent: it fails on 91d491238b1 with the same line and the same expected and received values. That commit is the main parent of the CI merge 3a245d3f687.
  • Tested merge: it also fails on the tested-merge tree 94b5b8d6593, which equals this PR's head tree.
  • Current main: it still fails on 4bc00fc6f22.
  • How these runs were made: each ran node scripts/run-vitest.mjs on that file in an isolated Linux container.
  • First failing main commit: 08eaf404075. It passes on that commit's parent 84cab039664.

This PR changes only src/infra/client-credential-store.ts, src/infra/device-identity-store.ts and src/infra/state-migrations.device-identity.test.ts. The failing test file and its helper test/helpers/qa-gateway-test-lifetime.ts have the same blobs on main and in the tested merge.

Landing through the attributed pre-existing-failure route, under a scoped maintainer instruction for this one failure. Review: Codex autoreview at P2 with high thinking and source context, on this exact head; it found no P0 to P2 issues.

@fuller-stack-dev
fuller-stack-dev merged commit 372e89d into openclaw:main Nov 27, 2026
145 of 148 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

@fuller-stack-dev
fuller-stack-dev deleted the fix/doctor-device-identity-read-only-inspection branch November 27, 2026 17:56
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…ock (#206513)

Doctor's legacy device identity detection reads each identity through
read-only credential custody, which still opened the local credential store
read-write, switched it to exclusive locking and began an IMMEDIATE
transaction. Three such opens ran on every healthy doctor --fix, and while
another client held the store's write lock each waited the full busy timeout
and then reported no invalid identity.

Inspection now opens the store read-only and reads committed rows in a
deferred transaction with the same schema, integrity and receipt checks. A
hot rollback journal still goes through custody, which can roll it back.

(cherry picked from commit 372e89d)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…ock (openclaw#206513)

Doctor's legacy device identity detection reads each identity through
read-only credential custody, which still opened the local credential store
read-write, switched it to exclusive locking and began an IMMEDIATE
transaction. Three such opens ran on every healthy doctor --fix, and while
another client held the store's write lock each waited the full busy timeout
and then reported no invalid identity.

Inspection now opens the store read-only and reads committed rows in a
deferred transaction with the same schema, integrity and receipt checks. A
hot rollback journal still goes through custody, which can roll it back.
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…ock (#206513)

Doctor's legacy device identity detection reads each identity through
read-only credential custody, which still opened the local credential store
read-write, switched it to exclusive locking and began an IMMEDIATE
transaction. Three such opens ran on every healthy doctor --fix, and while
another client held the store's write lock each waited the full busy timeout
and then reported no invalid identity.

Inspection now opens the store read-only and reads committed rows in a
deferred transaction with the same schema, integrity and receipt checks. A
hot rollback journal still goes through custody, which can roll it back.

(cherry picked from commit 372e89d)

Follow-up audit: e2e0974 independently skips no-op state schema repair. Keep the identity-store fix limited to the existing read-only snapshot behavior.

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

Labels

impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. security-sensitive-changed size: S 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