Skip to content

fix(auth): self-heal stale shared auth store ownership - #152111

Closed
xydigitLybnnnn wants to merge 4 commits into
openclaw:mainfrom
xydigitLybnnnn:fix/151620-oauth-login-reports-auth-profi
Closed

xydigitLybnnnn wants to merge 4 commits into
openclaw:mainfrom
xydigitLybnnnn:fix/151620-oauth-login-reports-auth-profi

Conversation

@xydigitLybnnnn

@xydigitLybnnnn xydigitLybnnnn commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Related: #151620

What Problem This Solves

Fixes saved model credentials remaining unavailable to a running process after another process relocates the shared auth store.

User Impact

Running readers discover the new store without a Gateway restart. Healthy local credentials remain usable when an inherited legacy store has a matching recorded refusal. No new configuration, migration, or provider-authentication behavior is introduced.

Why This Change Was Made

Refresh nonterminal legacy ownership between loads, then keep one database identity throughout each load. Synchronous reads, metadata, and write adapters use the captured owner or acquired connection; asynchronous reads retain their prepared owner across awaits; inherited refusals match the failed legacy database path without re-reading mutable ownership. A later load observes relocation without mixing credential rows, runtime state, provenance, or refusal diagnostics.

Preserves xydigitLybnnnn's resolver repair and contributor ancestry. Maintainer follow-up addresses independently reproduced asynchronous and synchronous interleavings.

Evidence

  • Persistent readers and separate synthetic credential writers verify cross-process relocation, including runtime-first discovery.
  • Five original async races, six synchronous read/composition races, and three inherited-refusal races failed before their respective repairs.
  • Original focused coverage: 236 tests across 14 suites. Revised synchronous coverage: 144 tests across 11 suites; final refusal/owner rerun: 40 tests across five suites. These runs overlap and are not additive.
  • All 31 final selected static checks passed. Independent review of the exact revised candidate found no actionable P0–P2 defects.
  • Local tests use synthetic credentials, not live provider authentication. Earlier-head CI passed; this revision requires its own exact-head hosted CI.

The original contributor evidence below is historical. Resolver-only async sufficiency claims and its runtime-proof gap are superseded by the additional runtime consistency repair and regression coverage described above.

Original contributor investigation and proof (historical)

What Problem This Solves

Issue #151620 — openclaw models auth login --provider openai reported the credential as saved, openclaw models auth list showed the new OAuth profile, but the gateway's model routes still saw zero usable openai profiles and rejected the model with:

route decision: {"kind":"rejected","reason":"explicit-order",
  "message":"Explicit auth order for openai has no usable profiles."}

The failure survived repeated doctor --fix runs and only cleared after the gateway process was restarted — the classic "CLI sees it, the gateway does not" split.

Root cause

resolveSharedAuthStoreOwnership() in src/agents/auth-profiles/path-resolve.ts pinned the resolved owner of the shared auth store for the life of the process:

const cached = sharedAuthStoreOwnershipByDatabasePath.get(databasePath);
if (cached) {
  return cached;
}

with the comment "Pin each root once so later row changes require an owner-controlled restart".

Relocating config_machine_state.auth.sharedStore is inherently cross-process: openclaw models auth login runs in its own process and writes {"location":"state-db"} while moving the credential into <stateDir>/state/openclaw.sqlite (prepareFreshSharedAuthStoreWrite() → initializeFreshSharedAuthStore()). A long-lived Gateway/TUI process that booted before that login keeps its cached legacy-main owner and therefore keeps reading the now-empty <stateDir>/agents/main/agent/openclaw-agent.sqlite.

The only existing invalidation is in-process (reloadSharedAuthStoreOwnership(), driven by the login's models.authRefresh gateway notification). When that notification is not delivered or is rejected — gateway unreachable, different state root, or a warning that is simply printed and skipped — the stale pin survives until a real restart.

state-db is a one-way terminal state: production code (shared-store-bootstrap.ts, state-migrations.shared-auth-store.ts) only ever writes it, never back to legacy-main. legacy-main (including an absent row) is not terminal, so it must not be pinned.

The fix

src/agents/auth-profiles/path-resolve.ts — pin only the terminal state and re-read the non-terminal one:

  • a cached state-db owner is returned as-is: terminal, so steady state keeps zero extra reads;
  • a cached legacy-main owner re-reads config_machine_state.auth.sharedStore and self-heals to state-db when another process relocated the store;
  • while the row still resolves to legacy-main, the same ownership object is returned, so the legacy-inspection memoization in shared-store-bootstrap.ts (a WeakSet keyed on object identity) keeps working; the stale comments in both files were rewritten to describe what is actually pinned.

The same rule now applies to the off-thread owner read. resolveSharedAuthStoreOwnershipAsync() returned any cached owner — including a non-terminal legacy-main — while the synchronous resolveSharedAuthStorePath() had already self-healed to the state database. runtime-read.ts pairs the two to choose between the shared reader and the prepared per-database readers, so the relocated path resolved to a reader that was never prepared (agentReads.get(databasePath) is undefined) and the read threw. The asynchronous resolver now re-reads the non-terminal owner through the same worker operation, keeps the state-db pin, preserves the process-stable legacy object, and still lets an explicit commit/reload that lands while the read is in flight win.

Tests in src/agents/auth-profiles/path-resolve.shared-store.test.ts:

  • the case that codified the bug — "reloads ownership after an explicit out-of-process auth mutation", which asserted legacy-main after an out-of-process write — now asserts the relocation is observed;
  • new: an absent ownership row resolves to legacy-main and then observes an out-of-process relocation, for both the plain and the aliased state root;
  • new: the asynchronous owner resolver observes the same relocation and agrees with the synchronous shared path (this fails against the pinned legacy cache);
  • new: a resolved state-db owner stays pinned after the ownership row disappears (no fallback);
  • new: the same ownership object is returned while a root stays legacy-main.

Evidence

1. Cross-process relocation — BEFORE (exit 1) vs AFTER (exit 0)

Harness: logs/real_behavior/issue-151620-evidence/harness/cross-process-repro.mts with login-write.mts. A long-lived process resolves the shared-store owner before any login exists; a separate process then performs a real login write; the long-lived process resolves again, loads the runtime auth snapshot and runs the real route-auth selection.

The login write uses the product write path — upsertAuthProfile() → saveAuthProfileStore({ sharedStoreWrite: true }) → prepareFreshSharedAuthStoreWrite() → initializeFreshSharedAuthStore() — i.e. exactly the migration openclaw models auth login performs.

$ git checkout upstream/main -- src/agents/auth-profiles/path-resolve.ts   # pre-fix logic
$ OPENCLAW_STATE_DIR=/tmp/repro151620-xproc \
    node --import ./scripts/tsx.mjs .../harness/cross-process-repro.mts
state dir: /tmp/repro151620-xproc
boot ownership: {"location":"legacy-main"}
child ownership after login: {"location":"state-db"}
child shared path after login: /tmp/repro151620-xproc/state/openclaw.sqlite
login process exit: 0
after-login ownership: {"location":"legacy-main"}
after-login shared path: /tmp/repro151620-xproc/agents/main/agent/openclaw-agent.sqlite
resolved profile ids: []
route decision: {"kind":"rejected","reason":"explicit-order","message":"Explicit auth order for openai has no usable profiles."}
RESULT: still pinned to the legacy store, route rejected
exit=1
$ node --import ./scripts/tsx.mjs .../harness/cross-process-repro.mts   # this branch
state dir: /tmp/repro151620-xproc
boot ownership: {"location":"legacy-main"}
child ownership after login: {"location":"state-db"}
child shared path after login: /tmp/repro151620-xproc/state/openclaw.sqlite
login process exit: 0
after-login ownership: {"location":"state-db"}
after-login shared path: /tmp/repro151620-xproc/state/openclaw.sqlite
resolved profile ids: ["openai:[email protected]"]
route decision: {"kind":"selected","selection":{"kind":"selected","source":{"kind":"profile","profileId":"openai:[email protected]","mode":"oauth","readiness":"ready","cooldown":"clear"},"route":{"api":"openai-chatgpt-responses","baseUrl":"https://chatgpt.com/backend-api/codex","authRequirement":"subscription", ...}}}
RESULT: relocation observed, subscription route selected
exit=0

The rejected route in the BEFORE run is the issue's exact error string; the AFTER run selects the openai subscription route instead.

Transcripts: harness/before-fix.txt, harness/after-fix.txt.

2. Real CLI login process against the running process (product entry)

Harness: harness/cli-login-cross-process.mts. Same shape, but the relocating process is the real CLI — openclaw models auth paste-token, the automation entry that models auth login itself points users at. Note the warning the CLI prints in both runs: it saved the credentials and could not refresh the running gateway, which is exactly the silent failure the issue describes.

$ git checkout upstream/main -- src/agents/auth-profiles/path-resolve.ts   # pre-fix logic
$ OPENCLAW_STATE_DIR=/tmp/repro151620-cli \
    node --import ./scripts/tsx.mjs .../harness/cli-login-cross-process.mts
state dir: /tmp/repro151620-cli
boot ownership: {"location":"legacy-main"}
[cli] Auth profile: openai:[email protected] (openai/token)
[cli] Warning: Model auth changes were saved, but the local Gateway could not refresh them. Run `openclaw gateway restart` to apply the saved changes.
cli login exit: 0
after-login ownership: {"location":"legacy-main"}
after-login shared path: /tmp/repro151620-cli/agents/main/agent/openclaw-agent.sqlite
resolved profile ids: []
route decision: {"kind":"rejected","reason":"explicit-order","message":"Explicit auth order for openai has no usable profiles."}
[cli] Auth state store: /tmp/repro151620-cli/state/openclaw.sqlite
[cli] Profiles:            <- empty: the credential it just "saved" is not the one it reads back
RESULT: still pinned to the legacy store, route rejected
exit=1
$ node --import ./scripts/tsx.mjs .../harness/cli-login-cross-process.mts   # this branch
state dir: /tmp/repro151620-cli
boot ownership: {"location":"legacy-main"}
[cli] Auth profile: openai:[email protected] (openai/token)
[cli] Warning: Model auth changes were saved, but the local Gateway could not refresh them. Run `openclaw gateway restart` to apply the saved changes.
cli login exit: 0
after-login ownership: {"location":"state-db"}
after-login shared path: /tmp/repro151620-cli/state/openclaw.sqlite
resolved profile ids: ["openai:[email protected]"]
route decision: {"kind":"selected","selection":{"kind":"selected","source":{"kind":"profile","profileId":"openai:[email protected]","mode":"token","readiness":"ready","cooldown":"clear"},"route":{"api":"openai-chatgpt-responses","baseUrl":"https://chatgpt.com/backend-api/codex","authRequirement":"subscription", ...}}}
[cli] Agent: main
[cli] Auth state store: /tmp/repro151620-cli/state/openclaw.sqlite
[cli] - openai:[email protected] [openai/token]
RESULT: relocation observed by the running process, route selected
exit=0

The CLI keeps printing the same "could not refresh" warning in both runs — the fix removes the need for that refresh: the running process now self-heals from the ownership row the CLI wrote.

Transcripts: harness/cli-before.txt, harness/cli-after.txt.

3. Target suites

$ node scripts/run-vitest.mjs run src/agents/auth-profiles/path-resolve.shared-store.test.ts \
    src/agents/auth-profiles/shared-store-bootstrap.runtime.test.ts
 ✓  ... > resolves an absent ownership record to legacy-main and observes out-of-process relocation
 ✓  ... > observes ownership relocated by an out-of-process auth mutation
 ✓  ... > keeps a resolved state-db owner pinned after the ownership row disappears
 ✓  ... > returns the same ownership object while a root stays legacy-main
 ✓  ... > resolves the relocated store to the canonical shared state database
 ✓  ... > keeps an agent-local store local under shared-state ownership
 ✓  ... > ignores runtime-only external CLI profiles when displaying store ownership
 ✓  ... > caches ownership independently for each canonical state root
 Test Files  1 passed (1)
      Tests  8 passed (8)
[test] passed 2 Vitest shards in 160.91s

4. Project gates

$ pnpm run check:changed
[check:changed] line-cap growth ratchet
Line-cap ratchet OK: 3 changed source files; no new violations or over-cap growth.
[check:changed] max-lines suppression ratchet
max-lines ratchet OK: 822 grandfathered suppressions.
[check:changed] assertion SAFETY comment ratchet
assertion SAFETY ratchet OK: 3808 files, 11148 grandfathered assertions.
[check:changed] lint core changed files
Found 0 warnings and 0 errors.
[check:changed] runtime import cycles
Import cycle check: 0 runtime value cycle(s).
check:changed exit=0
$ pnpm test:changed
 Test Files  1 failed | 897 passed | 1 skipped (899)
      Tests  1 failed | 11216 passed | 4 skipped (11221)

The single failure is
src/process/spawn-broker/relay.test.ts > brokered process lifecycle owners > retains relay control and lineage through root exit and tree cancellation
with service child cleanup did not complete before its hard deadline. It is unrelated to this change (different subsystem, not in the diff) and is specific to the local repro container, which runs as PID 1 sleep infinity with ~1.4k zombie processes and a full swap file. The same file passes on the host checkout of this branch:

$ node scripts/run-vitest.mjs run src/process/spawn-broker/relay.test.ts      # host, same source and dist
 ✓  ... > retains relay control and lineage through root exit and tree cancellation 802ms
 ✓  ... > forwards the ownedWorker start gate and disconnect through the broker 71ms
 Test Files  1 passed (1)
      Tests  2 passed (2)
[test] passed 1 Vitest shard in 56.69s

The changed-file suites themselves are green in both environments (evidence §3). pnpm run check:changed was re-run on the async-reader follow-up head and is still exit 0.

5. Async owner / synchronous path agreement (async reader follow-up)

resolveSharedAuthStoreOwnershipAsync() carried the same non-terminal pin, and runtime-read.ts pairs it with the synchronous shared path to pick a reader. The new regression fails against the pinned legacy cache and passes with the fix:

$ # async resolver temporarily restored to "return any cached owner"
$ node scripts/run-vitest.mjs run src/agents/auth-profiles/path-resolve.shared-store.test.ts
 ×  ... > observes out-of-process relocation through the asynchronous owner resolver
 Test Files  1 failed (1)
      Tests  1 failed | 8 passed (9)
[test] FAILED (exit 1)
$ node scripts/run-vitest.mjs run src/agents/auth-profiles/path-resolve.shared-store.test.ts \
    src/agents/auth-profiles/shared-store-bootstrap.runtime.test.ts \
    src/agents/auth-profiles/store.async-read.test.ts \
    src/agents/auth-profiles/oauth-refresh-fence.async.test.ts
 Test Files  3 passed (3)
      Tests  23 passed (23)
[test] passed 2 Vitest shards in 176.22s

Transcripts: harness/async-owner-test-prefix.txt (failing), harness/async-owner-test.txt and harness/auth-suites-after-async-fix.txt (passing).

Linked context

Fixes #151620.

Tests and validation

  • src/agents/auth-profiles/path-resolve.shared-store.test.ts + shared-store-bootstrap.runtime.test.ts + store.async-read.test.ts + oauth-refresh-fence.async.test.ts — 23 passed
  • pnpm run check:changed — exit 0 (ratchets, targeted oxlint, tsgo core, tsgo core test shards, dead-code scan, guards)
  • pnpm test:changed — 11216 passed, 1 failed in src/process/spawn-broker/relay.test.ts (container-only process-cleanup deadline; the same file passes 2/2 on the host, see evidence §4). This run predates the async-reader follow-up commit; the changed-file suites were re-run on that commit (23 passed, evidence §5) and CI re-runs the full matrix on the pushed head.
  • pnpm build (triggered lazily by the CLI in evidence §2) — exit 0
  • Cross-process relocation harness — exit 0; the same harness against the pre-fix path-resolve.ts — exit 1 with the issue's exact error message

Risk checklist

  • The change only affects a root whose cached owner is legacy-main; a root already on state-db keeps the previous zero-read behaviour (terminal pin).
  • legacy-main stays object-identical while unchanged, so the WeakSet-based legacy inspection in shared-store-bootstrap.ts is not re-run per call.
  • The 256-root cache limit and the existing error behaviour are unchanged; the limit is now only enforced for roots that are not already cached.
  • No config, migration, IPC protocol, polling, or new option is introduced; the re-read goes through the existing read-only state-database accessor.
  • The asynchronous owner read keeps its off-thread worker read; only roots that are still legacy-main pay the extra read, and state-db roots still short-circuit without touching the worker.
  • An explicit commit/reload that lands while the off-thread read is in flight still wins, as before.
  • No production path writes state-db back to legacy-main, so the terminal pin cannot go stale; if such a path were ever added, the pin would lag until the process restarts (unchanged from today's behaviour).

Declared gaps

  • No live OpenAI/ChatGPT account was used; credentials are synthetic fixtures.
  • Only Linux x64 was exercised; macOS/launchd and Windows were not.
  • The "long-lived process" in the harness is a real process that resolves the owner through the real modules and then survives the cross-process write; a full gateway process was not started, so the evidence is process-level rather than UI-level.
  • No end-to-end regression through runtime-read.ts: the host state-worker context is unavailable in the unit environment (SqliteWorkerError: unavailable), so the async/sync agreement is locked at the resolver boundary instead.

🤖 AI-assisted: This PR was developed with AI assistance.

A long-lived process pinned the shared auth store owner (`legacy-main`) for
its entire lifetime. When a sibling process ran `models auth login` and
relocated the store into the state DB, the pinned process kept resolving the
old, empty legacy database, so every `openai/*` route failed with
"Explicit auth order for openai has no usable profiles." while the CLI still
listed the saved profile.

Only `state-db` is a one-way terminal state. Re-read `auth.sharedStore`
while a root is still `legacy-main` so a process observes an out-of-process
relocation without a restart. Keep the cached object identity while the
legacy owner is unchanged so downstream legacy inspection stays memoized.

Fixes openclaw#151620
@clawsweeper

clawsweeper Bot commented Sep 18, 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.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Sep 18, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 18, 2026
@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 6, 2026, 9:30 AM ET / 13:30 UTC (Revision 6).

ClawSweeper review

What this changes

The PR lets running processes discover relocated shared credentials while keeping each credential load and write tied to one consistent database owner.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/agents/auth-profiles/sqlite.ts. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: current main and v2026.9.8 still retain the stale ownership pin. The prior race findings are resolved, the runtime evidence supports the repair, and no new actionable defect was found.

Priority: P1
Reviewed head: 01296b8f6034e2e5fa96e8ff4bedf84fe0db9f0d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused ownership repair with meaningful production-path evidence and resolved prior findings; merge conflicts are a separate integration blocker.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Matching full-body terminal traces exercise the real credential writer and CLI against a persistent reader, showing relocation discovery and successful route selection after the repair. Revised evidence covers production reader subprocesses and runtime-first discovery; race tests are supplemental. Synthetic credentials do not prove live provider login, which this patch does not change. No stored-data model changes, so data-model migration proof is not applicable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Matching full-body terminal traces exercise the real credential writer and CLI against a persistent reader, showing relocation discovery and successful route selection after the repair. Revised evidence covers production reader subprocesses and runtime-first discovery; race tests are supplemental. Synthetic credentials do not prove live provider login, which this patch does not change. No stored-data model changes, so data-model migration proof is not applicable.
Evidence reviewed 9 items Central defect remains on current main: Both synchronous and asynchronous ownership resolvers return any cached owner, including legacy-main. A running process therefore still requires explicit invalidation to discover cross-process relocation.
Latest release retains the pin: The v2026.9.8 source also returns cached legacy ownership. No merged fixing PR supplied in the related context establishes that this repair has shipped.
Introduced ownership repair: The pinned merge-base-to-head patch refreshes nonterminal ownership and carries prepared database paths through asynchronous row decoding and composition. Synchronous adapters likewise capture one target. These changes resolve the concrete prior ownership findings.
Findings None None.
Security None None.

How this fits together

OpenClaw’s auth store combines shared and agent-local credentials with account selection state. CLI credential writes feed this store, which supplies credentials to running model routes.

flowchart TD
  A[CLI saves credentials] --> B[Shared SQLite store]
  B --> C[Resolve shared owner]
  D[Agent local credentials] --> E[Capture database targets]
  C --> E
  E --> F[Read and combine credentials]
  F --> G[Model route selection]
Loading

Before merge

  • Complete next step (P2) - Resolve the conflicts with current main, preserve the synchronous and asynchronous ownership repairs, and obtain review and focused validation on the resulting head.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +48, Tests +580. Total +628 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 11 226 178 +48
Tests 7 596 16 +580
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 822 194 +628

Review metrics

Metric Value Why it matters
Ownership repair growth production net +48 LOC; tests net +580 LOC Production growth is justified by carrying one captured database identity through reads and writes; regression coverage dominates the expansion.

Stored data model

Persistent data-model change detected: serialized state: src/agents/auth-profiles/candidate-stores.ts, serialized state: src/agents/auth-profiles/runtime-snapshot-owner.ts, serialized state: src/agents/auth-profiles/sqlite-read.ts, serialized state: src/agents/auth-profiles/upsert-with-lock.ts, unknown-data-model-change: src/agents/auth-profiles/sqlite.ts, unknown-data-model-change: src/agents/auth-profiles/store.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #151620
Summary: This PR is a candidate repair for the linked credential-visibility issue; neighboring auth reports retain distinct or unconfirmed causes.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Retain automatic relocation discovery and consistent per-load ownership within current main’s auth worker architecture, preserving existing credentials, account order, and refusal checks.

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

Yes, source establishes the stale-cache path: resolve legacy ownership, relocate the store in another process, then reload credentials without explicit invalidation. Supplied before/after traces corroborate it; this read-only review did not execute current main.

Is this the best way to solve the issue?

Yes, refreshing nonterminal ownership between loads and carrying the captured target through each load is a focused owner-level repair. Integration must preserve the newer worker architecture.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The remaining main-branch defect can leave running model routes unable to use credentials that the CLI successfully saved.
  • 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. Sufficient (terminal): Matching full-body terminal traces exercise the real credential writer and CLI against a persistent reader, showing relocation discovery and successful route selection after the repair. Revised evidence covers production reader subprocesses and runtime-first discovery; race tests are supplemental. Synthetic credentials do not prove live provider login, which this patch does not change. No stored-data model changes, so data-model migration proof is not applicable.
  • proof: sufficient: Contributor real behavior proof is sufficient. Matching full-body terminal traces exercise the real credential writer and CLI against a persistent reader, showing relocation discovery and successful route selection after the repair. Revised evidence covers production reader subprocesses and runtime-first discovery; race tests are supplemental. Synthetic credentials do not prove live provider login, which this patch does not change. No stored-data model changes, so data-model migration proof is not applicable.

Evidence

What I checked:

  • Central defect remains on current main: Both synchronous and asynchronous ownership resolvers return any cached owner, including legacy-main. A running process therefore still requires explicit invalidation to discover cross-process relocation. (src/agents/auth-profiles/path-resolve.ts:73, c78c2638ec74)
  • Latest release retains the pin: The v2026.9.8 source also returns cached legacy ownership. No merged fixing PR supplied in the related context establishes that this repair has shipped. (src/agents/auth-profiles/path-resolve.ts, fc23bc864e45)
  • Introduced ownership repair: The pinned merge-base-to-head patch refreshes nonterminal ownership and carries prepared database paths through asynchronous row decoding and composition. Synchronous adapters likewise capture one target. These changes resolve the concrete prior ownership findings. (src/agents/auth-profiles/runtime-read.ts:353, 01296b8f6034)
  • Complete captured runtime evidence inspected: The full REST body matches captured SHA-256 4e2922b2e88e5c9040a97d3b12172968ac7da56ed84f457006d9312c19e362e5 and all 18,725 UTF-16 units were inspected. Historical before/after traces exercise the real credential writer and CLI paste-token entrypoint: the persistent reader changes from an empty profile list and rejected route to the saved profile and selected route. Revised evidence additionally reports persistent reader subprocess coverage, runtime-first discovery, and repaired interleavings. Synthetic credentials were used; no live provider authentication is claimed. (01296b8f6034)
  • Existing storage contract preserved: The patch retains existing SQLite tables, keys, serialized payloads, state coercion, and relocation producer. The changed state merge consumes an already-coerced store. No stored-data model or migration is introduced, so the previous generic migration-proof blocker is not supported by this diff. (src/agents/auth-profiles/persisted.ts:832, 01296b8f6034)
  • Refusal boundaries remain intact: An inherited read failure is ignored only when its failed legacy database path matches a recorded refusal; shared-state and unrelated failures still propagate. Existing async admission and file-identity checks remain. The patch changes database selection within the existing auth owner without adding a new principal or permission grant. (src/agents/auth-profiles/inherited-store.ts:21, 01296b8f6034)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RomneyDa: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (5 earlier review cycles)
  • reviewed 2026-09-18T19:49:49.848Z sha 58754fe :: blocked before merge. :: [P1] [P1] Carry consistent ownership through asynchronous auth reads
  • reviewed 2026-09-18T20:24:56.553Z sha 0f151dd :: blocked before merge. :: [P1] [P1] Carry one shared owner through the entire asynchronous load
  • reviewed 2026-09-18T21:02:01.539Z sha 0f151dd :: blocked before merge. :: [P1] Carry one shared owner through the entire asynchronous load
  • reviewed 2026-09-18T22:46:02.433Z sha ee74a13 :: blocked before merge. :: [P2] Capture one ownership result for synchronous database targets
  • reviewed 2026-09-18T23:53:13.362Z sha 01296b8 :: blocked before merge. :: none

resolveSharedAuthStoreOwnershipAsync() kept returning a cached legacy-main
owner while the synchronous shared path resolver had already self-healed to
the state database. runtime-read.ts pairs the two to choose a reader, so the
relocated path resolved to a reader that was never prepared and the read threw.

Re-read the non-terminal owner off-thread exactly like the synchronous
resolver, keep the one-way state-db pin, preserve the process-stable legacy
object, and add an async-resolver regression that fails against the pinned
legacy cache.
@xydigitLybnnnn

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The async reader finding is fixed in 0f151dd6285:

  • resolveSharedAuthStoreOwnershipAsync() no longer returns a cached non-terminal legacy-main. It re-reads the row through the same off-thread worker operation, keeps the one-way state-db pin, preserves the process-stable legacy object, and still lets an explicit commit/reload that lands while the read is in flight win. The asynchronous owner and resolveSharedAuthStorePath() can no longer disagree, so runtime-read.ts always finds a prepared reader for the relocated path.
  • Regression: path-resolve.shared-store.test.ts > observes out-of-process relocation through the asynchronous owner resolver — fails against the pinned legacy cache (1 failed | 8 passed) and passes with the fix; the neighbouring async suites are 23 passed. Both runs are in PR body §5.
  • pnpm run check:changed was re-run on this head: exit 0.
  • Declared gap: no runtime-read.ts-level end-to-end test, because the host state-worker context is unavailable in the unit environment (SqliteWorkerError: unavailable). The agreement is locked at the resolver boundary instead; noted in the PR body.

The 8 failing checks on this head are not from this PR. They come from upstream main after this branch's base: 35bc869cf5c (#152064) declares const { promisify } = await import("node:util") twice in each of src/infra/sqlite-readonly-worker.test.ts (49/51), src/infra/sqlite-readonly-location.cancellation.test.ts (21/23) and src/infra/sqlite-snapshot-staging.cancellation.test.ts (23/25) — present at upstream/main tip. That fails check-lint-core-4, check-test-types-core-2 (TS2451: Cannot redeclare block-scoped variable 'promisify'), check-additional-boundaries and the compact shards that import those files. No file in this PR's diff is involved, and the previous head was green on the same checks before that upstream commit landed.

@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@fuller-stack-dev fuller-stack-dev self-assigned this Sep 18, 2026
Carry the prepared database path through async reader selection, row decoding, refusal diagnostics and final credential composition. Preserve relocation discovery on subsequent loads and add runtime/interleaving regression coverage.

Co-authored-by: xydigitLybnnnn <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: L and removed size: S labels Sep 18, 2026
@fuller-stack-dev
fuller-stack-dev requested a review from a team September 18, 2026 22:40
Capture synchronous owner and adapter identity, keep prepared reads stable across relocation, and match inherited refusals to the failed legacy database. Preserve contributor ancestry and strengthen race regressions.
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 18, 2026
@xydigitLybnnnn

Copy link
Copy Markdown
Contributor Author

Closing: this branch targets the pre-rewrite auth-profiles ownership module, which upstream has since rewritten (new shared-store-bootstrap*, noteCommittedSharedAuthStoreOwnership, worker-based async owner reads, and the runtime-read/store-update ownership guard). It now conflicts across 13 files and can no longer merge as-is.

A narrow re-implementation of just resolveSharedAuthStoreOwnership/...Async (pin only the one-way terminal state-db, re-read the non-terminal legacy-main, keep the process-stable object while unchanged) was tried against current main: it passes the path-resolve.shared-store spec, but regresses usage.write-admission.test.ts ('refuses a changed shared owner before a queued warm/cold health update' now resolves instead of rejecting), i.e. a queued write can proceed across a shared-owner relocation. So the fix cannot be a resolver-only change; it needs the coordinated guard/reader changes this branch originally carried.

The problem from #151620 is still present on main (resolveSharedAuthStoreOwnership still pins the first-read owner). Closing this stale branch in favor of a fresh, narrowly-scoped PR against current main once the ownership-guard interaction is worked out. #151620 stays open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

OAuth login reports "Auth profile saved" but gateway model routes see zero usable openai profiles (2026.9.4, multi-agent, custom OPENCLAW_STATE_DIR)

2 participants