Repository navigation
fix(auth): keep agent creation working during the first session - #169779
Conversation
Preserve captured absence in async auth reads instead of treating normal first database creation as replacement. Never open or adopt the new file through the earlier read; subsequent preparations observe it. Existing-file replacement, owner revocation, maintenance, and cleanup checks remain. The async secrets loader in #169111 exposed the older guard. The unchanged Gateway overlap test fails before this repair and passes afterward. A focused reader regression fails with the same error on the original code. Validation: six tests pass at maxWorkers=1, 141.32s command wall (reader 9.96s Vitest, new case 8ms; Gateway 114.12s). Core/agents test types, normal and boundary lint, formatting, and independent P2 review pass. No schema, stored bytes, permissions, migration, or update changes.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: needs maintainer review before merge. What this changesAn auth reader prepared before an agent database exists now preserves its empty result when the first session creates that database. Example: One operator creates an agent while another creates the first session on main.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it repairs a current first-session overlap failure with a focused change, and no actionable patch defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway credential preparation captures database identity and live read ownership, then returns persisted auth rows or an empty result to the auth-store composition layer. flowchart TD
A[Gateway agent creation] --> B[Credential preparation]
B --> C[Prepared auth reader]
C --> D[Live owner checks]
D --> E[Captured absent path]
D --> F[Captured existing file]
E --> G[Empty noncacheable rows]
F --> H[Readonly worker rows]
Technical reviewBest possible solution: Land the focused captured-absence repair while retaining existing-file identity checks and live owner admission. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically rejects captured absence after file creation; the PR reports matching before/after reader and Gateway regressions, which were inspected but not executed during this read-only review. Is this the best way to solve the issue? The change fixes the owning invariant directly: absence remains an empty snapshot, while every path that actually reads credentials retains its existing source and authority checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2c7cc827b309. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +4, Tests +25, Docs +3. Total +32 across 3 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 12, 2026, 4:58 AM ET / 08:58 UTC. |
|
Merged via squash.
|
…claw#169779) Preserve captured absence in async auth reads instead of treating normal first database creation as replacement. Never open or adopt the new file through the earlier read; subsequent preparations observe it. Existing-file replacement, owner revocation, maintenance, and cleanup checks remain. The async secrets loader in openclaw#169111 exposed the older guard. The unchanged Gateway overlap test fails before this repair and passes afterward. A focused reader regression fails with the same error on the original code. Validation: six tests pass at maxWorkers=1, 141.32s command wall (reader 9.96s Vitest, new case 8ms; Gateway 114.12s). Core/agents test types, normal and boundary lint, formatting, and independent P2 review pass. No schema, stored bytes, permissions, migration, or update changes.
What Problem This Solves
Creating an agent can fail with
UNAVAILABLE: Auth profile database file identity changed during its readwhen another operator starts the first session on the main agent.User Impact
Agent creation and the first session can complete concurrently. An auth read that captured an absent agent database keeps its empty, non-cacheable result; the next preparation observes the newly created file. No credentials are read from or adopted out of that new file by the earlier read.
Why This Change Was Made
The async credential preparation in #169111 exposed an older identity guard that treated initial file creation as replacement. The failing Gateway test reproduces the exact overlap. A diagnostic trace confirmed that secret preparation captured an absent
maindatabase and later rejected its normal first creation.Only captured existing files need the replacement check. Root admission, maintenance and agent-owner revocation checks remain unchanged, as do existing-file replacement refusal and cleanup. There is no schema, stored-data, permission, migration, or update behavior change.
Evidence
pnpm test src/agents/auth-profiles/sqlite-read.test.ts src/gateway/server.agents.config-readiness.test.ts --maxWorkers=1: six tests pass, 141.32s command wall on a loaded host. Reader file: 9.96s Vitest wall, new test 8ms; Gateway file: 114.12s wall, 45.09s test body. The single-file negative-control command took 55.94s. PR CI supplies broad proof; no retries, timeout changes, or remote leases.git diff --checkpass.