Skip to content

fix(tui): reload auth store ownership after login - #130349

Merged
RomneyDa merged 2 commits into
mainfrom
fix/tui-local-auth-persistence
Aug 29, 2026
Merged

RomneyDa merged 2 commits into
mainfrom
fix/tui-local-auth-persistence

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

Summary

Local TUI /auth now reloads shared auth-store ownership after a successful out-of-process login. The login child can relocate the shared auth store into state/openclaw.sqlite, while the already-running TUI remained pinned to its pre-login legacy owner and could not see the new credential until restart.

This keeps ownership process-stable during normal runtime and reloads it only at the explicit auth lifecycle boundary. No schema, migration, config, fallback, or compatibility path changes. The PTY assertion now reads the effective runtime store rather than the retired agent-local persistence row.

Evidence

  • Before: exact built-CLI PTY test failed at src/tui/tui-pty-local.e2e.test.ts:1592; the auth child exited 0, the shared auth_profile_stores row contained the credential, and the caller still resolved the empty legacy agent row.
  • After: focused real PTY auth flow passed (1 passed, 25 skipped), including persisted credential digest, unchanged local model, and post-auth inference.
  • pnpm test src/agents/auth-profiles/path-resolve.shared-store.test.ts src/tui/tui-command-handlers.test.ts: 225 passed.
  • pnpm check:changed: passed.
  • pnpm build: passed.

Production LOC: +18/-1 (net +17) for the explicit cross-process ownership reload boundary. Tests: +26/-2.

AI-assisted: yes.

@RomneyDa
RomneyDa requested a review from a team as a code owner August 26, 2026 20:04
@clawsweeper

clawsweeper Bot commented Aug 26, 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 agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Aug 26, 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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 6:16 PM ET / 22:16 UTC.

ClawSweeper review

What this changes

The PR reloads shared auth-store ownership and clears prepared auth snapshots after a successful non-Codex local TUI login so the next inference uses the new credential.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

The branch appears to repair the current-main stale ownership cache for a retained local TUI and its focused PTY test reaches the next provider request. It remains open for maintainer handling because it is member-authored/protected and the Codex-specific exemption could not be checked in the required sibling source checkout.

Priority: P1
Reviewed head: 61df1eb6176e3ba07dc96b2827e87120727f3415
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused retained-TUI evidence is strong, while the unverified Codex-specific ownership exemption and avoidable production duplication limit confidence.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The changed production owner is the local TUI auth-child completion path; the PR body reports a built-CLI PTY run and the test asserts the next request’s bearer credential. The contributor is a repository member, so the external-contributor proof gate does not apply.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The changed production owner is the local TUI auth-child completion path; the PR body reports a built-CLI PTY run and the test asserts the next request’s bearer credential. The contributor is a repository member, so the external-contributor proof gate does not apply.
Evidence reviewed 7 items Changed lifecycle boundary: After a successful local auth child, the introduced branch reloads ownership and clears runtime auth snapshots only when the child was not the Codex CLI.
Ownership cache repair: The introduced reload rereads the authoritative machine-state record and replaces the cache entry for the selected state database, whereas the normal resolver intentionally returns its pinned value.
Runtime consumer: Clearing snapshots notifies the prepared-runtime lifecycle; an inherited-store mutation invalidates every affected retained owner and queues a rebuild before request-visible publication.
Findings None None.
Security None None.

How this fits together

The local TUI runs provider login in a child process, while the parent process retains prepared model runtimes and auth snapshots. The change refreshes that parent-owned state before the next model request.

flowchart LR
  A[Local TUI auth command] --> B[Provider login child]
  B --> C[Shared auth store]
  C --> D[Ownership reload]
  D --> E[Runtime snapshot reset]
  E --> F[Prepared model runtime]
  F --> G[Next provider request]
Loading

Decision needed

Question Recommendation
Can an auth/runtime owner verify from the Codex CLI source that its successful login cannot mutate OpenClaw’s shared auth-store ownership or prepared runtime credentials? Confirm the isolated Codex store: Inspect the Codex login persistence path and retain the non-Codex-only refresh when it cannot alter OpenClaw-owned auth state.

Why: The introduced conditional preserves a distinct external auth-store owner; direct inspection is required by the applicable repository policy, but the sibling checkout is unavailable here.

Before merge

  • Resolve merge risk (P1) - The successful-login path changes retained credential selection and adds 20 production lines; a smaller cache-invalidate-and-resolve implementation was not demonstrated.
  • Resolve merge risk (P1) - The Codex CLI branch is deliberately excluded from the refresh, but the required direct Codex source inspection was unavailable; this is a reviewer limitation, not missing contributor proof.
  • Complete next step (P2) - An auth/runtime owner must verify the directly invoked Codex login contract; no safe repair dispatch is warranted from this review.
Agent review details

Security

None.

PR surface

Source +20, Tests +31. Total +51 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 20 0 +20
Tests 2 35 4 +31
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 55 4 +51

Review metrics

Metric Value Why it matters
Production versus test delta production +20/-0; tests +35/-4 The focused test growth covers cache ownership and a built local-TUI request boundary, while production growth implements the new lifecycle edge.

Merge-risk options

Maintainer options:

  1. Verify the Codex ownership boundary (recommended)
    Confirm the Codex login persistence contract before merging the conditional exemption.
  2. Accept the documented exemption
    Land the scoped refresh only if an auth owner accepts the remaining external-contract verification gap.

Technical review

Best possible solution:

Keep the explicit non-Codex login lifecycle boundary, absorb the reload into the canonical ownership resolver to avoid duplicate parsing logic, and confirm that Codex login never writes OpenClaw’s shared auth store.

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

Yes, from source: current main pins shared-store ownership in a process cache while the auth child persists out of process, and the introduced PTY scenario asserts the next same-process request uses the new credential.

Is this the best way to solve the issue?

Unclear: refreshing the explicit external mutation boundary is the correct owner layer, but the preserved Codex exemption requires direct dependency-contract confirmation.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: Without the refresh, a successful local login can leave the already-running TUI unable to use its new credential until restart.
  • merge-risk: 🚨 compatibility: The PR changes how an existing retained TUI process observes an auth-store relocation after login.
  • merge-risk: 🚨 auth-provider: It changes the prepared credential state used by the next provider request after authentication.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The changed production owner is the local TUI auth-child completion path; the PR body reports a built-CLI PTY run and the test asserts the next request’s bearer credential. The contributor is a repository member, so the external-contributor proof gate does not apply.

Evidence

What I checked:

  • Changed lifecycle boundary: After a successful local auth child, the introduced branch reloads ownership and clears runtime auth snapshots only when the child was not the Codex CLI. (src/tui/tui.ts:1409, 61df1eb6176e)
  • Ownership cache repair: The introduced reload rereads the authoritative machine-state record and replaces the cache entry for the selected state database, whereas the normal resolver intentionally returns its pinned value. (src/agents/auth-profiles/path-resolve.ts:91, f1e891f42974)
  • Runtime consumer: Clearing snapshots notifies the prepared-runtime lifecycle; an inherited-store mutation invalidates every affected retained owner and queues a rebuild before request-visible publication. (src/agents/prepared-model-runtime.ts:596, 61df1eb6176e)
  • Focused end-to-end coverage: The built local-TUI PTY scenario submits /auth, then asserts the very next mock-model request carries the newly entered bearer credential. (src/tui/tui-pty-local.e2e.test.ts:1618, 61df1eb6176e)
  • Current-main necessity: The pinned main parent logs auth-child success but has neither the ownership reload nor snapshot reset, so current main does not yet address the retained-process behavior. (src/tui/tui.ts:1405, f12dab5833ae)
  • Codex-contract inspection gap: The conditional path directly invokes codex login and intentionally skips OpenClaw auth-store refresh; the required sibling Codex checkout was absent, so that external ownership contract was not independently verified. (src/tui/tui.ts:1379, 61df1eb6176e)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Confirm the Codex login persistence boundary from its source.
  • Refactor the reload to reuse the canonical ownership resolver if that preserves the explicit mutation boundary.

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 (4 earlier review cycles)
  • reviewed 2026-08-26T20:10:26.906Z sha 51b6871 :: needs changes before merge. :: [P1] Refresh the prepared auth runtime after child login
  • reviewed 2026-08-26T20:54:20.945Z sha 51b6871 :: found issues before merge. :: [P1] Refresh the prepared runtime after child login
  • reviewed 2026-08-26T21:10:12.231Z sha 346f798 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T21:16:10.743Z sha 2e427f7 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 26, 2026
@RomneyDa
RomneyDa marked this pull request as draft August 26, 2026 20:56
@RomneyDa

Copy link
Copy Markdown
Member Author

Addressed the current P1 on exact head 346f798b21746d2bdc4aa139a2fa0c88e3c2ba02.

After a successful OpenClaw auth child exits, the retained TUI now reloads shared-store ownership and clears the published runtime-auth snapshots through the existing mutation boundary. Prepared model-runtime owners observe that invalidation and rebuild from the newly persisted credential before the next inference. Codex-owned login remains outside this shared-store path.

The retained-TUI regression now authenticates the actual tui-pty-mock provider and requires the very next same-process model request to carry Authorization: Bearer <new credential> instead of the startup credential.

Proof:

  • focused auth/TUI unit tests: 225/225 pass
  • exact built-CLI retained-TUI PTY regression: pass
  • pnpm build: pass
  • pnpm tsgo:all: pass
  • formatting and git diff --check: pass
  • test-audit: real child-auth + retained runtime + request-boundary assertion; no test-only production seam
  • autoreview: clean, 0.98
  • repair delta: production +5/-1, tests +9/-2

@clawsweeper re-review

@clawsweeper

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

@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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@RomneyDa
RomneyDa marked this pull request as ready for review August 29, 2026 06:52
@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@RomneyDa
RomneyDa force-pushed the fix/tui-local-auth-persistence branch from 2e427f7 to 61df1eb Compare August 29, 2026 22:12
@clawsweeper clawsweeper Bot removed the rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. label Aug 29, 2026
@clawsweeper clawsweeper Bot added the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Aug 29, 2026
@RomneyDa
RomneyDa merged commit 6d33511 into main Aug 29, 2026
240 checks passed
@RomneyDa
RomneyDa deleted the fix/tui-local-auth-persistence branch August 29, 2026 22:29
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 30, 2026
* fix(tui): reload auth store ownership after login

* fix(tui): refresh auth runtime after login
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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. size: S 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