Skip to content

fix(auth): keep agent creation working during the first session - #169779

Merged
steipete merged 1 commit into
mainfrom
ci/fix3-auth-readiness
Oct 12, 2026
Merged

steipete merged 1 commit into
mainfrom
ci/fix3-auth-readiness

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Creating an agent can fail with UNAVAILABLE: Auth profile database file identity changed during its read when 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 main database 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

  • The unchanged Gateway test reproduced the CI failure on main. It passes after the fix, with all overlapping create/delete, session, publication, and duplicate-delete assertions intact.
  • A new focused reader regression fails before the fix with the same identity error and passes afterward. It proves the old read never opens the new file and a subsequent reader observes it. All five reader cases pass, including replacement and revocation refusal.
  • 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.
  • Production core types, agents-other test types, scoped type-aware lint, boundary lint, formatting, and git diff --check pass.
  • Independent P2 review: scoped-clean.

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.
@clawsweeper

clawsweeper Bot commented Oct 12, 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: 8fc1604177502b8c131ca203e3ac5496bfac7c9b
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/sqlite-read.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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: XS labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

An 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.

  • Before: Agent creation can fail with UNAVAILABLE: Auth profile database file identity changed during its read.
  • After: The earlier reader returns an empty, non-cacheable result without opening the new database; subsequent preparation observes the file.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with meaningful reported Gateway regression coverage; execution was not independently repeated.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor-proof gate does not apply to this maintainer-authored PR; supplied evidence reports the real Gateway overlap regression and focused negative control, with no shipped-entry-point artifact supplied.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Agent creation can fail when another operator starts the first main-agent session.
Reason: The maintainer-authored change restores concurrent operations through the existing auth owner without adding configuration, storage formats, or another policy path.

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
Reviewed head: 8fc1604177502b8c131ca203e3ac5496bfac7c9b

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway 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]
Loading

Technical review

Best 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

  • Captured auth database identity validation changes intended behavior with a stated reason (1d4202d: Keep captured credential-source admission valid through asynchronous reads and cleanup.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +4, Tests +25, Docs +3. Total +32 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 5 1 +4
Tests 1 25 0 +25
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 33 1 +32

Labels

Label changes:

  • add P2: Concurrent agent creation and initial main-session creation can fail, with a limited overlap-dependent blast radius.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Concurrent agent creation and initial main-session creation can fail, with a limited overlap-dependent blast radius.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 October 12, 2026, 4:58 AM ET / 08:58 UTC.

@steipete
steipete merged commit 97775a4 into main Oct 12, 2026
118 of 119 checks passed
@steipete
steipete deleted the ci/fix3-auth-readiness branch October 12, 2026 09:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: XS 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