Skip to content

fix: keep cookie caches in memory when Keychain is disabled - #2409

Closed
gmkbenjamin wants to merge 2 commits into
steipete:mainfrom
gmkbenjamin:fix/keychain-disabled-session-refresh
Closed

fix: keep cookie caches in memory when Keychain is disabled#2409
gmkbenjamin wants to merge 2 commits into
steipete:mainfrom
gmkbenjamin:fix/keychain-disabled-session-refresh

Conversation

@gmkbenjamin

@gmkbenjamin gmkbenjamin commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Keep cookie/session caches in process when Disable Keychain access is on, so Cursor refresh can reconcile the active session without Keychain persistence.
  • Restrict the fallback to the cookie category; OAuth and other credential categories remain unavailable.
  • Clear process-local cookies whenever Keychain access is toggled.
  • When clearing while Keychain is disabled, remove the process-local copy but report the durable operation as incomplete; an inaccessible persistent Keychain row is never falsely reported as deleted.
  • Rebase the focused change on current main and drop the unrelated CI-only/dashboard commits.

Fixes #2408

Test plan

  • swift test --filter 'KeychainCacheStoreTests|CookieHeaderCacheConditionalMutationTests' — 26 tests
  • make check
  • TZ=UTC make test — 724 selections, 61/61 groups passed, no retries
  • Packaged live provider matrix with Disable Keychain access enabled; every enabled provider refreshed and the reported Cursor session-change error did not recur
  • Live: toggle Keychain access and confirm disabled-mode process memory is cleared
  • CI green

Safety

Claude Auto background CLI remains blocked while Keychain is disabled; CodexBar cannot constrain Keychain access or prompts from that external process.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5d474c42ac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBarCore/KeychainCacheStore.swift Outdated
@gmkbenjamin

Copy link
Copy Markdown
Contributor Author

CI failure looks unrelated to this PR:

  • Failing: SpendDashboardControllerTests (groups.first?.totalCost nil/0 vs expected) on swift-test-macos (0, 2)
  • Same suite/same assertions failed on recent main (run 29958506345)
  • This PR’s suites passed: KeychainCacheStoreTests, CookieHeaderCacheConditionalMutationTests

Pushed an empty commit to retrigger CI (no admin rights to rerun the upstream workflow).

user and others added 2 commits July 28, 2026 22:48
Cursor refreshes failed with “session changed” because Keychain store/load
could not persist under Disable Keychain access. Use an in-process fallback
and clear it when the setting is toggled.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gmkbenjamin
gmkbenjamin force-pushed the fix/keychain-disabled-session-refresh branch from 16e148a to 8ff516c Compare July 28, 2026 12:58
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed July 28, 2026, 11:05 AM ET / 15:05 UTC.

ClawSweeper review

What this changes

Adds a process-local cache for browser-cookie sessions while Keychain access is explicitly disabled, clears it when that setting changes, and keeps OAuth and other cache categories unavailable.

Merge readiness

Blocked until real behavior proof is added - 3 items remain

The patch is a focused fix for the Cursor half of the Keychain-disabled refresh problem and includes the follow-up correction for truthful deletion reporting. It should stay open: current main does not contain this fallback, the related umbrella issue remains open, and the contributor still needs direct after-fix proof of the Keychain toggle lifecycle before merge.

Priority: P2
Reviewed head: 8ff516ce45772e86e1b54502bbb2abbed52c860c

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused implementation and test coverage look solid, but absent inspectable real-behavior proof keeps this below merge-ready quality.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR claims a packaged provider-matrix run, but it does not include inspectable after-fix output, logs, a recording, or a screenshot, and its own toggle-clearing check remains unchecked. Please add redacted evidence for the live refresh and off/on Keychain toggle; updating the PR body should trigger review, or ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR claims a packaged provider-matrix run, but it does not include inspectable after-fix output, logs, a recording, or a screenshot, and its own toggle-clearing check remains unchecked. Please add redacted evidence for the live refresh and off/on Keychain toggle; updating the PR body should trigger review, or ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Current-main gap: Current main has no disabled-access in-memory fallback for Keychain cache reads and writes; this PR adds that path for cookie entries.
Focused patch scope: The branch changes the access gate and cache store, adds focused cache and conditional-mutation tests, and documents the cookie-only fallback and incomplete deletion result.
Prior review addressed: The latest commit changes disabled-mode clearing to remove only process memory while returning failure because an inaccessible durable Keychain row cannot be proven deleted, addressing the earlier deletion-reporting concern.
Findings None None.
Security None None.

How this fits together

CodexBar refreshes browser-backed providers using cached session cookies, normally stored in its Keychain cache. The new path lets cookie session reconciliation continue during an explicitly Keychain-disabled run without persisting new credentials, then discards that process memory when the setting changes.

flowchart LR
  Setting[Advanced Keychain setting] --> Gate[Keychain access gate]
  Refresh[Cursor browser refresh] --> Cache[Cookie session cache]
  Gate --> Decision{Explicitly disabled?}
  Decision -->|No| Keychain[Persistent Keychain cache]
  Decision -->|Yes, cookie category| Memory[Process-local cookie cache]
  Cache --> Reconcile[Session ownership check]
  Reconcile --> Usage[Provider usage result]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR claims a packaged provider-matrix run, but it does not include inspectable after-fix output, logs, a recording, or a screenshot, and its own toggle-clearing check remains unchecked. Please add redacted evidence for the live refresh and off/on Keychain toggle; updating the PR body should trigger review, or ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The process-local cache is intentionally cleared on a Keychain setting transition, but the PR has not supplied direct after-fix evidence that an off/on toggle prevents disabled-mode cookies from resurfacing while normal refresh remains usable.
  • Complete next step (P2) - The remaining blocker is contributor-supplied real behavior proof from a macOS/provider setup; it cannot be safely produced by an automated repair lane.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch surface 6 files affected; 346 additions, 9 deletions The implementation is concentrated in two cache/gate files with two focused test files and supporting documentation.
Automated checks 9 of 9 checks successful The branch currently has a clean merge state and all reported CI checks pass; live lifecycle proof remains separate.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #2408
Summary: This PR is a candidate fix for the Cursor cookie-cache portion of the canonical Keychain-disabled refresh report; it does not cover the remaining Claude background-refresh behavior.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the cookie-only fallback and truthful clear failure semantics, then add redacted real-app or CLI evidence for a disabled refresh followed by an off/on Keychain toggle that shows the in-memory cookie is gone.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the cookie-only fallback and truthful clear failure semantics, then add redacted real-app or CLI evidence for a disabled refresh followed by an off/on Keychain toggle that shows the in-memory cookie is gone.

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

Yes in source terms: the linked report gives a concrete Cursor refresh path and the patch targets the disabled-Keychain cache persistence path. The review could not execute the macOS provider flow in this read-only environment.

Is this the best way to solve the issue?

Yes, provisionally: a cookie-only process-local fallback preserves the existing ownership check without widening OAuth access, and the follow-up commit avoids falsely claiming durable deletion. The missing live toggle proof is the remaining merge gate.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This addresses a provider refresh failure for users who intentionally disable Keychain access, with limited blast radius.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR claims a packaged provider-matrix run, but it does not include inspectable after-fix output, logs, a recording, or a screenshot, and its own toggle-clearing check remains unchecked. Please add redacted evidence for the live refresh and off/on Keychain toggle; updating the PR body should trigger review, or ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • steipete: The relevant current-main cache and Keychain surfaces are owned within this repository; file-level author provenance could not be established from the available read-only inspection environment. (role: repository owner and likely area steward; confidence: low; commits: 02b4ba278c81; files: Sources/CodexBarCore/KeychainCacheStore.swift, Sources/CodexBarCore/KeychainAccessGate.swift, docs/KEYCHAIN_FIX.md)

Rank-up moves

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

  • Post redacted live output, logs, or a short recording showing Cursor refresh succeeds with Keychain disabled.
  • Show that toggling Keychain access off then on clears the process-local cookie and does not report a durable delete that did not occur.

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.

@steipete

Copy link
Copy Markdown
Owner

Closing as superseded by #2426 (just merged), which includes this fallback scoped to cookie keys per the owner decision, plus the Claude-side fixes. Thanks @gmkbenjamin — your #2409 shape is what informed the final constraint.

@steipete steipete closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable Keychain access: Cursor "session changed during refresh" and Claude "No available fetch strategy"

2 participants