Skip to content

fix(auth): preserve shared profile ownership on fresh installs - #128192

Merged
vincentkoc merged 15 commits into
release/beta3-candidate-final-20260821from
fix/beta3-final-candidate-repair-20260823
Aug 23, 2026
Merged

vincentkoc merged 15 commits into
release/beta3-candidate-final-20260821from
fix/beta3-final-candidate-repair-20260823

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 23, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes an issue where a fresh or partially migrated installation could claim the shared authentication profile store before legacy JSON, SQLite, or pending migration evidence had been resolved. It also repairs two release-only test boundaries that could stall or omit the exact beta validation cases.

Why This Change Was Made

The authentication store now establishes ownership once at the shared-store boundary, fails closed to Doctor when legacy or unreadable evidence remains, and keeps shared writes on that owner without a schema bump. Doctor owns cleanup and migration, including dangling legacy links and source-set changes after confirmation. The Slack enterprise startup test uses a one-shot dispatch seam while retaining the real prepared identity and delivery path. The plugin-binding Docker smoke targets both current Vitest entrypoints and aggregates their two focused summaries.

The final Codex 0.149 approval receipt binds those bytes to the frozen candidate ancestry. This PR is rooted at frozen candidate 9a83cbf29d8f637cbe566d809811cb6a13c93664; it does not adopt later main changes.

User Impact

Fresh installs retain the canonical shared authentication store. Upgrades with legacy, dangling, unreadable, or incomplete migration state receive the Doctor-owned repair path instead of an unsafe ownership guess. A legacy OAuth source that appears after confirmation is left untouched and requires a fresh Doctor run.

Evidence

  • Exact head: 2423773af6d3e50e22a62f64bd63c4d5a18d58e5.
  • Auth/Doctor exact-head focused suites: 55 + 23 + 2 passed locally and on Blacksmith Testbox.
  • Slack provider auth.test suite: 26/26 passed on Blacksmith Testbox through the real prepared identity and delivery adapter.
  • Codex app-server protocol sync/check passed on Blacksmith Testbox with OPENCLAW_CODEX_REPO pinned to clean rust-v0.149.0 commit 758ef40f50c1a458425c7cfbf1eb12cbc07af0b0.
  • Codex 0.149 candidate-bound approval proof: 2/2 passed on exact head.
  • Hosted run 32635966167 proved the split command-escape cases pass as 2 + 1; its old single-summary validator then rejected the valid split. Narrow rerun 32636598043 proved the first summary could fall outside the tail-only scan. Exact head 2423773af6d streams the complete log in bounded 64 KiB chunks and still requires two summaries totaling exactly three. Narrow Blacksmith Testbox run 32636795756 passed with OK (3 focused tests).
  • Exact Codex source inspected at rust-v0.149.0 / 758ef40f50c1a458425c7cfbf1eb12cbc07af0b0: codex-rs/core/src/exec_policy_tests.rs:1010-1053, codex-rs/core/src/exec_policy_tests.rs:1331-1350, and codex-rs/core/src/exec_policy_tests.rs:2090-2108.

Scope And Risk

  • No SQLite schema bump.
  • Production growth establishes the shared-store ownership security invariant, fail-closed legacy evidence handling, deterministic Doctor migration/cleanup, and confirmation race safety.
  • Slack and command-escape changes are test/harness only.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added channel: slack Channel integration: slack scripts Repository scripts commands Command implementations docker Docker and sandbox tooling agents Agent runtime and tooling extensions: codex size: XL maintainer Maintainer-authored PR labels Aug 23, 2026
@vincentkoc vincentkoc self-assigned this Aug 23, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 7:20 AM ET / 11:20 UTC.

ClawSweeper review

What this changes

This PR backports shared authentication-store ownership and Doctor handling for legacy state to a beta candidate, while refreshing Slack, Docker, and Codex validation fixtures.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for human release-inclusion review. The shared-auth bootstrap is already present on current main, but this protected, member-owned draft targets a frozen beta candidate and needs exact-head upgrade/protocol validation before any backport decision.

Priority: P1
Reviewed head: 1008cdf3b4d6a329b1e3a4cdf5edf7b87c096c0d
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation aligns with current main, but exact beta validation and direct Codex-source verification remain material review gaps.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored PR is outside the external-contributor proof gate; its exact-head beta validation remains a release-inclusion requirement.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR is outside the external-contributor proof gate; its exact-head beta validation remains a release-inclusion requirement.
Evidence reviewed 6 items Current-main implementation: Current main contains the same fresh-store ownership bootstrap: it preserves legacy ownership when retired files, SQLite rows, pending cleanup, or unreadable state exist, and records global ownership only for a clean root.
Write-owner boundary: The write transaction calls the ownership bootstrap before choosing the agent or shared-state database, so fresh shared writes are routed through the canonical owner.
Current-main regression coverage: Current-main tests cover fresh ownership, legacy rows, pending cleanup, unreadable state, and the no-runtime-JSON-read boundary.
Findings None None.
Security None None.

How this fits together

Authentication profiles are written by setup and provider flows, then read by agent/provider routing. The shared-store bootstrap decides whether a clean installation uses the global state database or leaves legacy and incomplete migration state for Doctor repair.

flowchart LR
  A[Credential write] --> B[Shared auth ownership check]
  B --> C{Legacy or pending state?}
  C -->|No| D[Global state database]
  C -->|Yes| E[Doctor repair path]
  D --> F[Auth profile loader]
  E --> F
  F --> G[Provider authentication]
Loading

Decision needed

Question Recommendation
Should the beta candidate take this already-main shared-auth ownership backport after exact-head upgrade and protocol validation? Validate and retain the beta backport: Run the exact-head shared-auth upgrade/Doctor and hosted protocol checks, then keep the branch if legacy roots fail closed only to the documented repair path.

Why: This changes durable credential ownership and Doctor recovery on a protected release branch; only maintainers can accept that upgrade risk for the beta.

Before merge

  • Resolve merge risk (P1) - The beta candidate would change persisted credential ownership and intentionally stop on legacy, unreadable, or pending migration evidence until Doctor runs; exact-head fresh-install and upgrade validation is still needed.
  • Resolve merge risk (P1) - The patch adds a net 221 production lines for an auth-storage backport, so release inclusion should verify the owner boundary rather than rely only on focused unit suites.
  • Resolve merge risk (P1) - The changed Codex receipt names a specific upstream contract, but direct sibling-Codex source inspection was unavailable; its upstream behavior claim remains unverified.
Agent review details

Security

None.

PR surface

Source +237, Tests +480, Other 0. Total +717 across 20 files.

View PR surface stats
Area Files Added Removed Net
Source 11 495 258 +237
Tests 7 502 22 +480
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 2 2 0
Total 20 999 282 +717

Review metrics

Metric Value Why it matters
Production versus test delta production +474/-253 (net +221); tests/support +521/-25; generated/baseline +4/-4 The meaningful growth is in shared credential-owner and Doctor migration code, so beta inclusion needs upgrade evidence rather than treating this as test-only churn.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/agents/auth-profiles/legacy-source-diagnostic.test.ts, migration/backfill/repair: src/agents/auth-profiles/legacy-source-files.ts, migration/backfill/repair: src/commands/doctor-auth-flat-profiles.test.ts, migration/backfill/repair: src/commands/doctor-auth-flat-profiles.ts, migration/backfill/repair: src/commands/doctor-model-catalog-credentials.test.ts, serialized state: src/commands/doctor-auth-flat-profiles.test.ts, and 5 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Prove the beta upgrade path before merge (recommended)
    Validate clean roots plus legacy, unreadable, and pending-migration roots on the exact beta head before accepting the durable-owner change.
  2. Defer the backport
    Leave the beta candidate unchanged if the exact-head validation cannot prove that existing credential stores recover through Doctor without a dead end.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Run exact-head shared-auth upgrade, Doctor-recovery, and hosted protocol validation against the beta candidate before marking it ready.

Technical review

Best possible solution:

Use the current-main shared-store design as the sole canonical implementation and include it in the beta only after exact-head upgrade, Doctor-recovery, and hosted protocol checks show the beta remains operational.

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

No live reproduction was established in this read-only review; current source and focused tests define the fresh-root and legacy-state paths the beta validation must exercise.

Is this the best way to solve the issue?

Unclear; current main supports this owner-boundary design, but the best beta decision depends on exact-head upgrade and Doctor-recovery evidence plus the unavailable direct Codex contract check.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6c37eb01d9a1.

Labels

Label justifications:

  • P1: The PR changes authentication-profile ownership and recovery on a beta release path, where a bad upgrade can interrupt provider access.
  • merge-risk: 🚨 compatibility: Existing installations with legacy or incomplete state will take a stricter Doctor-owned recovery path after this change.
  • merge-risk: 🚨 auth-provider: The changed shared profile store selects where provider credentials are persisted and subsequently loaded.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored PR is outside the external-contributor proof gate; its exact-head beta validation remains a release-inclusion requirement.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame and the shared-store/Doctor history place this architecture with Peter Steinberger. (role: shared-auth feature owner and recent area contributor; confidence: high; commits: d2dad76ecde4, 63b18e6e5f49, 6405a59c45a2; files: src/agents/auth-profiles/shared-store-bootstrap.ts, src/agents/auth-profiles/sqlite.ts, src/commands/doctor-auth-flat-profiles.ts)
  • vincentkoc: History shows substantial prior work in the auth and Doctor surfaces in addition to this branch. (role: recent auth-persistence contributor; confidence: high; commits: 1008cdf3b4d6, 9a83cbf29d8f, 7186f0d65462; files: src/agents/auth-profiles/store.ts, src/agents/auth-profiles/upsert-with-lock.ts, src/commands/doctor-auth-flat-profiles.ts)

Rank-up moves

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

  • Run exact-head clean-root, legacy-root, unreadable-root, and pending-migration validation on the beta candidate.
  • Inspect the required Codex source checkout and verify the changed receipt against its named upstream commit before accepting it as proof.

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 (1 earlier review cycle)
  • reviewed 2026-08-23T10:55:20.759Z sha d1b7a4f :: needs maintainer review before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 23, 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:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 23, 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:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 23, 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:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head c3099598934cc1a7cea3209bf7f35cd2ebb4ac05 fixes the hosted command-escape proof parser after the split files reported 2 passed and 1 passed. The parser now requires exactly two shard summaries totaling exactly three focused tests. Local focused script checks and the candidate-bound Codex proof are green.

@clawsweeper

clawsweeper Bot commented Aug 23, 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:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head 2423773af6d3e50e22a62f64bd63c4d5a18d58e5 fixes the release-blocking evidence scan found by narrow run 32636598043: the first shard summary was outside the previous tail-only 64 KiB window. The validator now streams the complete log in bounded 64 KiB chunks and still requires exactly two summaries totaling exactly three tests. Focused script checks, a synthetic >64 KiB regression, and the rebound Codex proof are green.

@clawsweeper

clawsweeper Bot commented Aug 23, 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:

@vincentkoc

Copy link
Copy Markdown
Member Author

Maintainer release decision for exact head 2423773af6d3e50e22a62f64bd63c4d5a18d58e5:

ClawSweeper exact review run 32636971365 identified one P1 functional follow-up, with security cleared. After fresh shared ownership, an unflagged default-agent caller such as model auth logout can read the canonical shared profile, then route its update to an empty agent-local database and report removal without changing the shared row.

This is deferred from beta.3 under the explicit P0-only release scope. Repairing it now would expand the frozen candidate into another auth-owner refactor and invalidate the completed exact candidate, Codex, Doctor, Slack, and Docker proof. It is not a new secret-exposure or security boundary failure, and it does not regress the release blocker repaired by this PR.

Post-beta owner: steipete, at the canonical transaction boundary in src/agents/auth-profiles/sqlite.ts, with the reachable caller in src/cli/capability-cli/model.ts. The follow-up should derive shared-main ownership without the caller-provided sharedStoreWrite opt-in and add an unflagged fresh-root logout/import regression in src/agents/auth-profiles.sqlite-store.test.ts.

Current behavior evidence is retained in ClawSweeper run 32636971365 and exact source at src/agents/auth-profiles/sqlite.ts:673, src/cli/capability-cli/model.ts:415, and src/agents/auth-profiles.sqlite-store.test.ts:148.

@vincentkoc
vincentkoc marked this pull request as ready for review August 23, 2026 11:47
@vincentkoc
vincentkoc requested a review from a team as a code owner August 23, 2026 11:47
@vincentkoc
vincentkoc merged commit 554baf9 into release/beta3-candidate-final-20260821 Aug 23, 2026
95 checks passed
@vincentkoc
vincentkoc deleted the fix/beta3-final-candidate-repair-20260823 branch August 23, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: slack Channel integration: slack commands Command implementations docker Docker and sandbox tooling extensions: codex maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts 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.

1 participant