Skip to content

refactor(auth): await Copilot cache persistence - #144810

Merged
steipete merged 1 commit into
mainfrom
codex/async-copilot-cache
Sep 11, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/async-copilot-cache

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #144592

What Problem This Solves

Copilot token resolution still reads and writes its SQLite cache through synchronous persistence contracts. It needs to retain the cache operation before returning a token when persistence becomes asynchronous.

Why This Change Was Made

Use the existing asynchronous core keyed store and await both cache lookup and save. Preserve the shipped explicit cache-file and injected JSON callback options, credential scoping, expiry checks, and token exchange behavior.

User Impact

Authentication behavior and stored data stay compatible. A cache save finishes before token resolution returns. This is API groundwork; moving native SQLite execution into workers remains tracked by the umbrella issue.

Evidence

  • 30 focused tests and the full selected changed checks passed.
  • Fresh independent Codex review through P2 passed. The rebase onto the landed core-store prerequisite is patch-identical.
  • Synthetic loopback token exchange with real SQLite persistence and a second process verified cache reuse: the first exchange took 146.46 ms with one HTTP request; reopening took 5.02 ms with zero HTTP requests. These measure different paths and are not a speedup comparison.
  • Existing synchronous injected JSON callbacks remain supported. No real provider credentials were used.

@clawsweeper

clawsweeper Bot commented Sep 11, 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.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 11, 2026
@steipete
steipete marked this pull request as ready for review September 11, 2026 09:25
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Sep 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 5:31 AM ET / 09:31 UTC.

ClawSweeper review

What this changes

The retained Copilot authentication SDK helper now awaits cache reads and persistence, with tests covering delayed completion and failures.

Merge readiness

✅ Ready for maintainer review

Keep this useful, maintainer-protected PR open. Current main still uses synchronous cache operations, and the proposed conversion has no identified blocking defect.

Priority: P2
Reviewed head: 2a2df53ec28de23bcb14a601743db9f8f67c4c76

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused conversion with relevant SQLite observations, meaningful completion-order coverage, and no blocking finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR reports the changed token resolver exercising a loopback exchange with real SQLite and successful cache reuse in a second process without another HTTP request; delayed completion and rejection tests supplement those observations.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR reports the changed token resolver exercising a loopback exchange with real SQLite and successful cache reuse in a second process without another HTTP request; delayed completion and rejection tests supplement those observations.
Evidence reviewed 9 items Introduced change verified: The pinned merge-base comparison changes the internal cache contract, selects the existing asynchronous store, and awaits both operations. The public token resolver retains its parameters and Promise return contract.
Current main still needs this conversion: Fetched main retains synchronous cache load/save signatures and createCorePluginStateSyncKeyedStore. The latest supplied release, v2026.9.4, also calls cache.load and cache.save without awaiting them.
Release comparison: The released resolver already exposes asynchronous token resolution and explicit JSON adapters; this PR preserves that public contract while completing its internal asynchronous cache boundary.
Findings None None.
Security None None.

How this fits together

The retained SDK helper exchanges a GitHub credential for a Copilot token and caches it for reuse. This is separate from the bundled Copilot plugin’s current account-validation flow.

flowchart TD
  A[GitHub credential and domain] --> B[Await cache lookup]
  B --> C{Matching usable token?}
  C -->|Yes| F[Return token and endpoint]
  C -->|No| D[Exchange GitHub credential]
  D --> E[Await cache persistence]
  E --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -1, Tests +106. Total +105 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 8 9 -1
Tests 1 106 0 +106
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 114 9 +105

Review metrics

None.

Root-cause cluster

Relationship: partial_overlap
Canonical: #144592
Summary: This PR implements one cache-boundary slice of the broader asynchronous-storage program.

Members:

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

Technical review

Best possible solution:

Keep one cache persistence owner with awaited completion while preserving the retained SDK contract and existing stored entries.

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

Not applicable: this is asynchronous-contract groundwork, not a demonstrated current-main failure; source confirms the remaining synchronous cache boundary.

Is this the best way to solve the issue?

Yes: using the existing async store and awaiting its results is the narrowest conversion, without introducing another persistence owner or changing the public resolver signature.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against efb4ecf74370.

Labels

Label changes:

  • add P2: This is a bounded storage-contract improvement supporting coordinated asynchronous persistence work, without a demonstrated urgent runtime regression.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR reports the changed token resolver exercising a loopback exchange with real SQLite and successful cache reuse in a second process without another HTTP request; delayed completion and rejection tests supplement those observations.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR reports the changed token resolver exercising a loopback exchange with real SQLite and successful cache reuse in a second process without another HTTP request; delayed completion and rejection tests supplement those observations.

Label justifications:

  • P2: This is a bounded storage-contract improvement supporting coordinated asynchronous persistence work, without a demonstrated urgent runtime regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR reports the changed token resolver exercising a loopback exchange with real SQLite and successful cache reuse in a second process without another HTTP request; delayed completion and rejection tests supplement those observations.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports the changed token resolver exercising a loopback exchange with real SQLite and successful cache reuse in a second process without another HTTP request; delayed completion and rejection tests supplement those observations.

Evidence

What I checked:

  • Introduced change verified: The pinned merge-base comparison changes the internal cache contract, selects the existing asynchronous store, and awaits both operations. The public token resolver retains its parameters and Promise return contract. (src/plugin-sdk/provider-auth.ts:316, 2a2df53ec28d)
  • Current main still needs this conversion: Fetched main retains synchronous cache load/save signatures and createCorePluginStateSyncKeyedStore. The latest supplied release, v2026.9.4, also calls cache.load and cache.save without awaiting them. (src/plugin-sdk/provider-auth-copilot-cache.ts:64, efb4ecf74370)
  • Release comparison: The released resolver already exposes asynchronous token resolution and explicit JSON adapters; this PR preserves that public contract while completing its internal asynchronous cache boundary. (src/plugin-sdk/provider-auth.ts:263, 3a9d69db306c)
  • Same persistence owner and data contract: The async facade delegates to the same synchronous SQLite implementation. Cache owner, namespace, credential-derived key, eight-entry bound, eviction policy, TTL, serialized payload, and explicit file adapters remain unchanged; this does not move SQLite execution into workers. (src/plugin-state/plugin-state-store.ts:175, 2a2df53ec28d)
  • Completion and compatibility coverage: Four new cases exercise delayed load/save success and rejection through resolveCopilotApiToken, including reopening SQLite after successful completion. Existing tests cover synchronous JSON callbacks, credential rotation, domain mismatch, expiry, and transport failures. Tests were inspected, not executed during this read-only review. (src/plugin-sdk/provider-auth-copilot-cache.test.ts:17, 2a2df53ec28d)
  • Reported production-path observations: The captured PR body reports a synthetic loopback exchange using real SQLite, followed by cache reuse in a second process: one HTTP request on exchange and zero after reopening. It also reports 30 focused tests and selected checks passing. These are contributor-reported observations, not executions performed by this review. (2a2df53ec28d)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

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
steipete merged commit 1d4afe3 into main Sep 11, 2026
378 of 380 checks passed
@steipete
steipete deleted the codex/async-copilot-cache branch September 11, 2026 12:14
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 11, 2026
Preserve the reviewed harness while incorporating the landed benchmark prerequisite.

Punchcard-Session: coral-orchard-orchard-d4

* commit '4407ed19ac63b1c1c84a0cfe6eb4bbeca9c2322c': (1196 commits)
  fix(perf): isolate benchmark subprocess transport (#144159)
  refactor(auth): await Copilot cache persistence (#144810)
  refactor(web-fetch): exercise URL normalization through the public tool (#144887)
  fix(ollama): preserve hosted subdomain model context (#144891)
  fix(doctor): explain Codex plugin health failures (#144813)
  fix(channels): honor pinned accounts in Mattermost model menus (#144880)
  fix(update): failed-update records hide the triggering error behind the excerpt tail (#144729)
  fix(logging): preserve OpenClaw package references in diagnostics (#144808)
  fix: retain plugin detail tab selections while inspection loads (#144647)
  fix: keep discovered models when sign-in tokens renew (#144861)
  fix(update): preserve local package overrides (#89985)
  fix(update): resolve compatibility bridges within the runtime graph (#144831)
  chore(i18n): refresh native locales (#144856)
  fix: preserve child signal termination during CLI respawn (#144838)
  fix(text): hide encoded MiniMax tool envelopes (#126307)
  fix(subagents): deliver child replies that match the empty placeholder (#130647)
  fix(cli): reject blank message channel selectors (#144802)
  fix(telegram): preserve mixed text order and pending stop (#144839)
  fix(memory): restore FTS fallback for same-name view collisions (#144783)
  chore(release): close out 2026.9.4 on main (#144708)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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