Repository navigation
fix(auth): inherit the shared auth store once it owns credentials - #130264
Conversation
resolveLegacyInheritedAuthDir unconditionally selected the legacy main-agent directory as the read-through base, so on fresh installs (and post-relocation installs) the empty agent DB shadowed the canonical shared auth store: models auth paste-api-key printed success while every turn failed with missing-provider-auth. The resolver now returns the legacy directory only while resolveSharedAuthStoreOwnership reports legacy-main ownership; otherwise inheritance read-throughs to the shared store per docs/auth-credential-semantics.md. Sibling shadow sites in the models list catalog paths fixed with the same predicate; stale AGENTS.md security line corrected. Regression proves fresh shared credentials resolve with no agent-local profile, populated legacy stores stay authoritative pre-relocation, and local profiles still override the shared base.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 2:42 PM ET / 18:42 UTC. ClawSweeper reviewWhat this changesThis PR makes agent auth inheritance use the shared SQLite profile store once that store owns credentials, while retaining legacy main-agent reads during migration and fixing equivalent model-catalog paths. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open for normal maintainer landing review. The patch aligns runtime inheritance with the documented shared-store ownership contract and preserves the physical legacy directory for doctor/secrets paths; exact-head rebase, CI, and ownership-mode proof remain merge conditions. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherCredential setup persists provider profiles in a legacy main-agent database or the shared state database. Agent runtime, model listing, catalog discovery, and Gateway status read those profiles before selecting credentials for provider calls. flowchart LR
A[Credential setup] --> B[Shared-store ownership]
B --> C{Legacy main store?}
C -->|yes| D[Legacy agent profile store]
C -->|no| E[Shared state profile store]
D --> F[Agent and catalog lookup]
E --> F
F --> G[Provider credential resolution]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +12, Tests +101, Docs 0. Total +113 across 17 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land one canonical ownership-aware inherited-store resolver after a rebased exact-head run confirms fresh shared-store auth, legacy-main compatibility, and local-profile override precedence. Do we have a high-confidence way to reproduce the issue? Yes—current-main source shows the unconditional legacy directory, while the auth loader treats an omitted inherited directory as the shared-store base; the PR adds direct precedence coverage for that state. Is this the best way to solve the issue? Yes—the fix changes the owner-boundary selector rather than adding fallback readers, and retains a separate physical-directory helper for migration and secrets discovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8e39f583650a. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
The chat.history thinkingDefault regression on CI was a pre-existing isolate:false leak: a sibling test's agentDiscoveryMock catalog fixture (reasoning:false) survived on globalThis and clamped the level to off. The shared fixture-reset owner now clears discovery state for both full and suite-backed resets, and the test publishes its own catalog fixture.
|
Merged via squash.
|
|
Two adjacent gaps surfaced during this fix's ownership audit (out of scope here, recording for follow-up):
|
…deletion Two follow-ups from #130264: agent exec temporary state now preserves the original shared auth root, so temp-state runs read-through portable static profiles (local precedence and cooldowns preserved, no inherited-secret copies); and agent deletion safety consults resolveSharedAuthStoreOwnership, so the implicit legacy main owner is protected only while the legacy store owns credentials — post-relocation main is deletable and shared credentials provably survive. Explicitly bound inheritance owners stay protected.
…deletion (#130437) Two follow-ups from #130264: agent exec temporary state now preserves the original shared auth root, so temp-state runs read-through portable static profiles (local precedence and cooldowns preserved, no inherited-secret copies); and agent deletion safety consults resolveSharedAuthStoreOwnership, so the implicit legacy main owner is protected only while the legacy store owns credentials — post-relocation main is deletable and shared credentials provably survive. Explicitly bound inheritance owners stay protected.
…enclaw#130264) * fix(auth): inherit the shared auth store once it owns credentials resolveLegacyInheritedAuthDir unconditionally selected the legacy main-agent directory as the read-through base, so on fresh installs (and post-relocation installs) the empty agent DB shadowed the canonical shared auth store: models auth paste-api-key printed success while every turn failed with missing-provider-auth. The resolver now returns the legacy directory only while resolveSharedAuthStoreOwnership reports legacy-main ownership; otherwise inheritance read-throughs to the shared store per docs/auth-credential-semantics.md. Sibling shadow sites in the models list catalog paths fixed with the same predicate; stale AGENTS.md security line corrected. Regression proves fresh shared credentials resolve with no agent-local profile, populated legacy stores stay authoritative pre-relocation, and local profiles still override the shared base. * test(gateway): reset shared discovery state in the fixture-reset owner The chat.history thinkingDefault regression on CI was a pre-existing isolate:false leak: a sibling test's agentDiscoveryMock catalog fixture (reasoning:false) survived on globalThis and clamped the level to off. The shared fixture-reset owner now clears discovery state for both full and suite-backed resets, and the test publishes its own catalog fixture.
…deletion (openclaw#130437) Two follow-ups from openclaw#130264: agent exec temporary state now preserves the original shared auth root, so temp-state runs read-through portable static profiles (local precedence and cooldowns preserved, no inherited-secret copies); and agent deletion safety consults resolveSharedAuthStoreOwnership, so the implicit legacy main owner is protected only while the legacy store owns credentials — post-relocation main is deletable and shared credentials provably survive. Explicitly bound inheritance owners stay protected.
What Problem This Solves
On a fresh install (and any install after the doctor shared-store relocation),
openclaw models auth paste-api-keyprints success —Auth profile: anthropic:manual (anthropic/api_key)— but every turn fails withNo API key found for provider ... | missing-provider-auth.models statuseven displays the shared store with the profile present, so setup looks healthy while the runtime is dead: the worst silent-failure class. Found live during the 50-session cross-machine farm test (#129979), where it zeroed an entire run: 49/50 worker launches completed and every turn failed on missing auth.Why This Change Was Made
Root cause:
resolveLegacyInheritedAuthDirunconditionally selected the legacy main-agent directory as the read-through inheritance base. Perdocs/auth-credential-semantics.md, agent auth inheritance is read-through to the shared store (state/openclaw.sqlite, canonical after the doctor relocation — and from birth on fresh installs); the legacy directory is only meaningful while it still owns credentials. With the unconditional selection, a fresh install's empty main-agent DB shadowed the canonical shared store and the runtime never consulted it.resolveSharedAuthStoreOwnershipreportslegacy-main; otherwise inheritance resolves through the shared store (the existingundefined → resolveSharedAuthPathpath). Credential writes and the doctor relocation are unchanged — no dual-write, no new fallback reader.resolveLegacyInheritedAuthAgentDir) preserves doctor migration and secrets discovery, which genuinely address the legacy location.prepared-model-catalog-worker,models listcommand/rows/scoped-catalog) — fixed with the same predicate.AGENTS.mdsecurity line naming the per-agent DB as the profile home now states the shared-store + read-through contract (that stale line misdirected the initial diagnosis).User Impact
paste-api-key(and token/OAuth profiles in the shared store) work on the first turn of a fresh gateway, in any setup ordering. Pre-relocation installs keep their legacy-store behavior; agent-local profiles still override the shared base.Evidence
missing-provider-authon the unfixed build; after deploying this fix (only change), the probe turn repliedFIXED-OK, and a full 50-session dispatch+turn wave ran (50/50 dispatched in 29s; 38/50 turns completed end-to-end in 105s — the 12 failures are a separate workspace-reconciliation contention finding tracked in Worker launches die unrecoverably on transient network flap: fixed 120s admission deadline, cause-masking error, 25-min stuck-lane terminalization #129979).pnpm check:changedgreen; 287 tests across 11 focused files green; Codex autoreview clean (0.96).Production LOC: +38/-13; tests +91/-7.