Skip to content

fix(auth): coalesce and bound repeated keychain reads - #299

Merged
lg2m merged 81 commits into
mainfrom
fix/qq-keychain-persistence-20261013
Oct 16, 2026
Merged

lg2m merged 81 commits into
mainfrom
fix/qq-keychain-persistence-20261013

Conversation

@integrate-your-mind

@integrate-your-mind integrate-your-mind commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Take over and narrow the existing PR to stored-keyring read reuse only. The original 39-file stack is replaced by an 8-file diff against main. No Jev, diagnostics, installer, budget, client/TUI, signing or ACL changes remain. Original branch/history retained; no force-push or replacement PR.

CredentialStore clones now share a coordinator that coalesces cold concurrent reads for the same credential, endpoint context and durable credential epoch. Successful keyring reads are reused for up to five minutes, with at most 64 cached entries and 64 distinct active flights. Registration, endpoint binding and index integrity are checked before reuse. Failures fan out to existing followers but are not negatively cached; unwind/poison handling wakes waiters. File and Windows-protected file reads stay uncached. Codex refresh/deadline paths and xAI rereads under the refresh lock bypass the memo to preserve authoritative rereads. Initial valid xAI OAuth reads use the shared memo.

Scope and tradeoffs

  • This reduces repeated OS-keychain reads in one process. It does NOT establish macOS persistent authorization across binary updates or promise no OS prompts.
  • Changes made directly in the OS keychain may take up to five minutes to affect ordinary stored resolutions. Restart discards the process-local memo. QQ index mutations invalidate reuse through the durable epoch.
  • Expiry is a reuse deadline, not a memory-erasure deadline. Independently constructed stores do not share a memo.
  • Existing noninterruptible synchronous backend calls remain; follower/capacity waits can remain blocked behind one. Existing bounded async loader/timeouts are unchanged.
  • No protocol, schema, dependency, authentication-flow or plaintext-fallback changes.
  • Runtime change is test-only: preserve cancellation/no-plan-publication proof with a warm credential memo and additionally prove rotation forces fresh read/compilation. Sleep-baseline change relocates one existing line only.

Verification

Red regression committed first at 547b247: repeated resolution across clones read the fake keyring twice, failing left: 2, right: 1. Narrowed implementation: 77/77 qq-auth tests passed. Coverage includes cold same-key coalescing, independent keys, retryable failure, panic/poison wakeup, capacity recovery/revalidation, epoch/endpoint/index validation, deterministic expiry with external rotation/deletion, uncached file permissions, and existing OAuth freshness/failure regressions.

Independent static sub-agent review: Approve, no blocking introduced bug found. Parent inspected implementation and ran checks. Initial workspace run exposed a runtime test assuming every retry reads the backend; updated it to prove cancelled plan is not published even on a warm memo, then prove durable rotation forces both fresh read and compilation.

Final verified code head: 8859c82.

cargo xtask check

Head 8859c820b54e vs origin/main; 0 changed file(s); scope: full workspace.

Gate Result Tests Time Command
fmt pass 2.5s cargo fmt --all -- --check
lint pass 2.2s cargo xtask lint
clippy pass 16.3s cargo clippy --color never --workspace --all-targets --all-features -- -D warnings
test pass 2656/2656 passed, 15 skipped 307.1s cargo nextest run --color never --profile default --workspace
doctest pass 3.0s cargo test --color never --workspace --doc
minimal-clippy pass 5.8s cargo clippy --color never -p qq-provider --no-default-features --features test-support --all-targets -- -D warnings
minimal-test pass 211/211 passed, 0 skipped 8.5s cargo nextest run --color never --profile default -p qq-provider --no-default-features --features test-support

All gates passed in 345.4s.

The evidence tool reports 0 changed files for the full-workspace selection; the actual PR diff is 8 files, +1,215/-21 (initial narrowed head; review follow-up adjusts tests and xAI).

cargo xtask smoke: 6/6 passed (ask streaming, durable tool call, provider 401, resume, server SSE, doctor/config).

Performance and limitations

Fake-backend counts prove eight concurrent cold resolutions use one backend read, and repeated warm resolutions use no additional read. These are operation-count results, not measured macOS latency. No live macOS Keychain, signed-update, ACL-persistence or real-credential test was run on this Linux host. Diagnostics are deliberately excluded and no new diagnostics PR is necessary for this fix.

(cherry picked from commit 05c0772)

Copy link
Copy Markdown
Collaborator Author

Misa — bounded installer/scope review at c6852fa.

The retained installer is substantive, but this PR does not establish the original macOS update/Keychain outcome. Its own live-E2E note reports an update prompt; I have not independently reproduced the Darwin behavior or verified its certificate diagnosis. No trust/signing/security change is authorized by this review.

I fetched this head and compared install.sh by Git blob: 393ce7c3a25dd3a3230bec3af872ced824da5199, exactly identical to #287. Therefore the execution-reproduced hard-link publication/retry defect documented in #287 (comment) applies to these same installer bytes. This reuses exact-content evidence rather than rerunning the identical suite or claiming an independent macOS test.

Scope needs explicit reconciliation: the merge-base PR diff is 39 files, 6,664 additions and 259 deletions, including auth, runtime, approval and budget changes. It is not installer-only. Those inherited changes need their own requirement/authorship/review mapping; installer approval cannot cover the rest. I have not completed review or execution of all 39 files.

Disposition: needs installer recovery fix, full scope mapping, and actual macOS outcome qualification. Preserve Devin and other contributors' provenance. Full Rust execution on my cloud host is blocked by absent Cargo; no merge/deployment/readiness claim.

@integrate-your-mind integrate-your-mind changed the title wip(install): retained checksum-named payloads, atomic selector switch, rollback wip: preserve installer, recovery, auth and Jev stack; update Keychain issue unresolved Oct 15, 2026
@lg2m lg2m changed the title wip: preserve installer, recovery, auth and Jev stack; update Keychain issue unresolved fix(auth): coalesce and bound repeated keychain reads Oct 16, 2026
@lg2m
lg2m marked this pull request as ready for review October 16, 2026 03:45
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T05:55:48.339852Z 8859c82 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lg2m

lg2m commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Takeover complete at 97bc28c. Existing branch and PR retained, targeting main; draft removed. Final diff: 8 files, +1,215/-21. Jev, diagnostics, installer and unrelated stack removed from final diff.

Verification receipt: red backend-count regression before fix; 76/76 auth tests; full workspace 2,655/2,655 (15 skipped); minimal provider 211/211; doctests, fmt/lint/strict Clippy all pass; all six binary smoke scenarios pass. Independent static reviewer approved without blocking findings. Hosted build and fmt/lint/clippy/tests/smoke checks now also pass. GitHub reports MERGEABLE.

Scope limitation: this is process-local read coalescing and a bounded five-minute successful-read memo, not a claim of persistent macOS Keychain authorization across updates. External keychain changes can remain unobserved within that window. No native macOS credential/ACL trial was performed. No diagnostics PR was necessary. Ready for your review/merge; not merged automatically.

@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: 97bc28cd2a

ℹ️ 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 crates/qq-auth/src/tests.rs Resolved
Comment thread crates/qq-auth/src/tests.rs Resolved
Comment thread crates/qq-auth/src/xai.rs Resolved
@lg2m

lg2m commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

@codex review

Please review updated head 8859c82. All three previous conversations have fixes and verification replies and are resolved. No Jev/diagnostics/installer scope added. Full workspace 2656/2656 (15 skipped), minimal provider 211/211, all doctests/Clippy/lint/fmt and smoke 6/6 pass.

@lg2m

lg2m commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator
cargo xtask check

Head 8859c820b54e vs origin/main; 0 changed file(s); scope: full workspace.

Gate Result Tests Time Command
fmt pass 1.6s cargo fmt --all -- --check
lint pass 2.1s cargo xtask lint
clippy pass 6.9s cargo clippy --color never --workspace --all-targets --all-features -- -D warnings
test pass 2656/2656 passed, 15 skipped 333.2s cargo nextest run --color never --profile default --workspace
doctest pass 3.0s cargo test --color never --workspace --doc
minimal-clippy pass 0.2s cargo clippy --color never -p qq-provider --no-default-features --features test-support --all-targets -- -D warnings
minimal-test pass 211/211 passed, 0 skipped 2.4s cargo nextest run --color never --profile default -p qq-provider --no-default-features --features test-support

All gates passed in 349.4s.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 8859c820b5

ℹ️ 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".

@lg2m
lg2m merged commit 3e34eea into main Oct 16, 2026
8 checks passed
@lg2m
lg2m deleted the fix/qq-keychain-persistence-20261013 branch October 16, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants