Repository navigation
fix(github): speed up repeated publication account discovery - #149372
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 15, 2026, 10:19 PM ET / September 16, 2026, 02:19 UTC (Revision 8). ClawSweeper reviewWhat this changesCaches successful native GitHub credential lookups for account discovery and authenticated reads for 60 seconds, while keeping publication credential reads live. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful follow-up to the earlier credential-verification optimization: current main still launches native credential discovery repeatedly. No actionable introduced defect was found, and the maintainer-authored proposal explicitly documents its bounded account-switch delay. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway resolves GitHub identities for publication account choices and authenticated repository reads. This cache reduces repeated GitHub CLI launches without supplying cached credentials to publication preparation. flowchart TD
A[Account options and repository reads] --> B[Current caller and identity checks]
B --> C{Credential source}
C --> D[Native lookup cache]
C --> E[Live environment or managed credential]
D --> F[Verified account and authorized reads]
E --> F
G[Publication request] --> H[Fresh native credential and account check]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +93, Tests +155, Docs +5. Total +253 across 15 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep native discovery caching bounded and lifecycle-owned, preserve live publication and caller authorization, and retain the documented account-switch tradeoff. Do we have a high-confidence way to reproduce the issue? Yes, source establishes that consecutive options requests without an environment or managed credential repeatedly launch native token discovery; the body also supplies production latency measurements. This review did not execute that path. Is this the best way to solve the issue? Yes, the patch reaches the measured handler and reuses the existing identity owner while keeping publication fresh; its native-account freshness tradeoff is explicit. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 78052a3386b3. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
583ce9a to
3885ab3
Compare
3885ab3 to
be2c421
Compare
Repeated publication account discovery spawns gh auth token even when GitHub verification is already cached. Reuse successful native reads for 60 seconds across read preparations and options requests, with OAuth and profile lifecycle invalidation. Keep publication credential reads live. Follow up on #136223. Host login, logout, and account switching may take up to the read-cache TTL to appear in account options.
Bind the session ownership and publication recovery fixtures to the read/options preparer while preserving their existing owner and account assertions after the options handler cutover.
be2c421 to
305406c
Compare
|
Merged via squash.
|
…w#149372) * perf(github): cache native credentials for read options Repeated publication account discovery spawns gh auth token even when GitHub verification is already cached. Reuse successful native reads for 60 seconds across read preparations and options requests, with OAuth and profile lifecycle invalidation. Keep publication credential reads live. Follow up on openclaw#136223. Host login, logout, and account switching may take up to the read-cache TTL to appear in account options. * test(github): update publication options identity fixtures Bind the session ownership and publication recovery fixtures to the read/options preparer while preserving their existing owner and account assertions after the options handler cutover.
What Problem This Solves
Publish PR account discovery repeatedly launches GitHub CLI on a busy Gateway, delaying Control UI responses. On team.openclaw.ai on September 15,
sessions.github.optionsran 1,328 times from 15 connections in one hour: p50 4,279 ms, p90 6,637 ms, maximum 13,312 ms, and 5,948 seconds of aggregate request time. Each spawn from the 5.7 GB Gateway also blocked its main thread for about 52 ms infork().Related: #136223, which cached successful GitHub credential verification but left native token discovery live on every request.
User Impact
Repeated account-options requests reuse the host's successful native GitHub credential lookup for 60 seconds, including concurrent requests. Host
gh auth login/logout/switchchanges may take up to that TTL to appear in read/options results. Actual publication still obtains a live native credential; environment tokens, managed credentials, caller permissions, and session access keep their live checks.Why This Change Was Made
The options handler actually used publication preparation, so changing only the read-identity helper would miss the hotspot. Options now requests account facts through a dedicated read preparation backed by the same native-token cache as
prepareGitHubReadIdentity; it receives no publication environment. Publication preparation retains the uncached native reader.The cache is bounded to 32 successful entries, keyed by a hash of the full effective command environment, working directory, and absence-proof mode. It coalesces concurrent reads, expires after 60 seconds to match the existing verification TTL, and clears with verification-cache shutdown plus profile installation, rotation, retirement, removal, and personal disconnect. Pending old reads cannot repopulate a cleared cache. Failed token reads and anonymous-absence proofs remain uncached.
No configuration, schema, managed-identity authentication, OAuth protocol, subscription mechanics, or UI presentation changes.
Evidence
The candidate was rebased without conflicts onto main containing #149477 (
476fa7a270e), which resolves the alias-fixture dependency failures. Both lane commits remain patch-identical. Earlier unrelated main lint failures were fixed by #149349 and #149423. The fresh pushed head is305406c5d8c8e84bb7155117dbca0221ff4031eb; exact-head CI run 35046847413 passed, and the PR was merged as 1396e2b557b9.expected "vi.fn()" to be called once, but got 2 times. Both pass on the new head, including another native lookup after invalidation.node scripts/run-vitest.mjs test/scripts/pr-wrappers.test.ts— all 92 tests passed, including all 12 alias-delegation and refusal cases (421.43 seconds).node scripts/run-vitest.mjs src/agents/github-read-identity.test.ts src/agents/github-tool-identity.test.ts src/agents/github-managed-credential.test.ts src/agents/github-oauth-client.test.ts src/gateway/server-methods/sessions-github-read.test.ts src/gateway/server-methods/sessions-github.test.ts src/gateway/github-oauth-lifecycle.test.ts src/gateway/server-methods/board.github-actions.test.ts src/gateway/session-utils-store-lookup.test.ts src/gateway/github-publication-legacy-options.test.ts src/gateway/github-personal-publication.test.ts src/gateway/github-personal-publication-outcomes.test.ts— all 373 tests across 12 files passed (233.14 seconds).node scripts/check-changed.mjs— passed, including core/test typechecks, targeted lint, unchanged ratchets, and zero runtime import cycles.git diff --check— passed.Historical before/after measurements from the scoped regression harness: read identity 12.30 s / 2.74 GB peak RSS before, 14.21 s / 2.99 GB after; options handler 23.06 s / 2.81 GB before, 19.60 s / 2.75 GB after. These import-heavy mocked runs measure harness cost. They do not establish production latency or memory improvement.
The supplied production latency establishes the problem; the regressions prove eliminated repeated native spawns. The live Gateway was not modified or restarted. Failed native token lookups remain live, and an expired-cache request still pays the native command cost.
Warm request trace before this change
Citations below use the pre-change base
56fa637fbef619f752702ecd687688cf1620b0a7.gh auth token --hostname github.comonce per options request. This options path does not request anonymous proof, callgh auth status, or run thegit configstatus probe.GET https://api.github.com/user. Warm healthy requests therefore still spawn even when they make no GitHub network request.No other unconditional per-call spawn or full-store payload read was found. Fixed/shared
session.storediscovery can scan keys to find an agent; authorization already request-scopes that discovery, while receipt readers perform their own discovery. Propagating discovery context into receipt interfaces is left outside this measured native-token fix.