Skip to content

perf(github): serve stale Control UI reads during bounded refresh - #169143

Merged
steipete merged 4 commits into
mainfrom
steipete/perf-micro-github-reads-stale-while-revalidate-20260919
Oct 11, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/perf-micro-github-reads-stale-while-revalidate-20260919

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What problem this solves

Expired GitHub previews, publication account options, and repository searches wait for GitHub before the Control UI can respond, even when a previous successful result is available.

Change

Extract the board Actions stale-read mechanism into one bounded cache factory and reuse it for preview, repository search, and display-only credential verification. Expired successful metadata returns with stale: true while one bounded refresh runs. Publication still requests fresh verification. Every response and authenticated outbound request retains the current identity and requester checks.

The factory replaces the separate cache policies and preserves forced-refresh ordering, existing error cooldown, clear-time invalidation, and the bound on all active loads, including superseded work. The existing collection-runtime SDK subpath gains one factory; there is no new subpath or configuration. Production LOC is +312 / -230, net +82 (excluding tests, test support, and docs); the growth preserves those concurrency/lifecycle contracts and adds explicit freshness fields.

Cold reads, explicit preview refreshes, due OAuth token renewal, and detailed PR visibility/exact-head checks still await their authoritative owner. No Team state or real browser was used.

Evidence

A synthetic rig with 800 ms item/account latency and immediate repository-visibility responses on AWS Crabbox cbx_60d8e8bf5e38, baseline a17bd679979e1dc69bba795222c5dce5da750815, measured 25 expired reads after warm-up:

Read Before p50 / p99 After p50 / p99
github.preview 800.599 / 802.197 ms 0.130 / 0.272 ms
sessions.github.options 803.118 / 805.822 ms 2.889 / 5.604 ms

All 25 candidate responses carried the stale marker. Both versions made 26 upstream calls per surface, including warm-up; background completion is outside the request timing. Preview timings cover the preview loader; options timings use the RPC fixture. This is synthetic latency evidence, not a live deployment measurement.

The initial options regression failed against the old main implementation while the upstream request was held. The final authorization regressions use the real Gateway dispatch, managed profile files, and prepared identity owner. They hold repository admission, return the stale response, then remove or rotate the profile before releasing the response. The unchanged-profile case must complete refresh; the retired cases must prevent subsequent authenticated requests. Search retries similarly retain requester authorization across redirects and optional-auth retry.

Latest candidate replay on the isolated Linux rig: preview loader p50/p99 0.215 / 0.551 ms and sessions.github.options RPC 5.273 / 9.276 ms, again with all 25 results marked stale and 26 upstream calls per surface. The replay took 56.97 s. A first replay timed out during worker-backed fixture setup; correcting its artificial-clock handling fixed the benchmark without a product change.

The final focused run passed 10 files / 208 tests in 285.98 s. The isolated authority run passed all five cases in 45.85 s. Replacing the three affected modules with previous-head 794afc556f2f3e71c2adf3423a712b4da70ba08c made all four negative controls fail for the intended reason in 56.93 s: retired preview credentials reached GitHub, and search made five/three calls instead of two on redirect/401 retry. The fixed preview trace after repository admission is:

  • Unchanged profile: original credential on the item and final repository request.
  • Removed profile: no subsequent requests.
  • Rotated profile: no subsequent requests.

The changed gate passed format, line caps, SDK budgets and boundaries, all 28 core test type graphs, and core/extension/extension-test/script types. It then found seven unused exports in untouched Telegram and subagent-store files. Removing the entire PR patch and running the same scan at exact main 292766cf8575a5d477b41efea72ab50d7a9c6be9 reproduced all seven. The original gate remains red for that inherited finding; no skip flag was used. All subsequent native gate commands passed, including core/extension/script lint and runtime-cycle guards. Export-name collision checks and all six closure/CI-planning files passed (146 tests, 199.15 s).

Standalone test cost: pnpm test src/gateway/server-methods/control-ui.github-preview-refresh.test.ts --maxWorkers=1 passed all three cases in 53.936 s wall on the Linux rig (46.43 s Vitest duration, dominated by module preparation). The final personal-account correction preserves the prepared freshness fact while revalidating live selection. Its new RPC regression primes personal verification before shared verification, expires only the personal facts, and holds that refresh: both personal and top-level stale markers must survive. It fails on the preceding code and passes with the correction. The options and personal-authorization suites passed 33 tests in 181.33 s (new case 3.9 s); targeted lint and core/Gateway-methods typechecks also passed. Independent Codex review is clean.

The earlier rebase resolved only the SDK-budget conflict, retaining main’s four additional exports. Final-head CI run 38169251462 passed on 043bab854082ac0261bf32f7a0347e6de7cccf05, including all required checks (758 s wall for the full CI run). ClawSweeper reviewed that same head as ready with zero findings. Merged as ea4b186dbfcfe499ac985bbc5c7cb62d1310cc8f.

Earlier remote proof passed 525 selected tests, the export-name guard, closure/CI-planning checks, and a full build (262.6 s, 152 SDK subpaths). An initial cache lint error was corrected. Earlier-head CI had a terminal-layout failure also present on main run 38147604740, job 114494370832, at the same chat-panel-layout.e2e.test.ts:379 hidden-canvas assertion. Its status-probe failure was not reproduced on main and is not claimed as inherited; final-head CI will be assessed separately.

The first new authorization run on Hetzner cbx_cddc837cdf76 stopped at a test-context fixture error before testing behavior; that fixture was corrected. Subsequent Hetzner cbx_f21fb1068f08 source sync and full-resync stalled before executing any test and the lease was released. Final validation uses the authorized isolated Linux rig with the exact staged patch on 292766cf8575a5d477b41efea72ab50d7a9c6be9.

@clawsweeper

clawsweeper Bot commented Oct 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.

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 043bab854082ac0261bf32f7a0347e6de7cccf05
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/github-oauth-client.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/gateway/github-personal-oauth.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling plugin: file-transfer extensions: github GitHub plugin: link previews and reader size: L labels Oct 11, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR shares a bounded cache across GitHub readers so expired metadata can return immediately while refreshing.

Example: A GitHub preview is read after its 60-second cache expires.

  • Before: The Control UI waits for GitHub before receiving the preview.
  • After: The previous preview returns with stale: true while one bounded refresh runs.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, coherent implementation with previous blockers resolved; confidence rests on synthetic production-owner boundary evidence rather than a shipped-entry-point demonstration.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (logs): The supplied production-owner RPC authority harness exercises real managed profiles, held repository admission, allowed refresh completion, and rejection after profile removal or rotation; search controls cover revocation before redirect and optional-auth retry. Negative controls fail on the earlier implementation. The latest personal-freshness correction has a failing-before/passing-after RPC regression. These are synthetic boundary observations, not live browser proof, and satisfy the authority requirement for this maintainer-authored PR.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Previously successful GitHub previews, repository searches, and account options pause again when their cached metadata expires.
Reason: The measured latency reduction serves an existing workflow, and the maintainer-authored direction explicitly accepts returning marked stale display facts.

Merge readiness

✅ Ready for maintainer review

Keep this PR open for landing: it provides a useful latency improvement, resolves the previous review findings, and introduces no further actionable defect found in this review.

Priority: P2
Reviewed head: 043bab854082ac0261bf32f7a0347e6de7cccf05

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not exercise these stale reads through a running browser or deployed Gateway; ordinary shipped-entry-point proof is exempt for this maintainer-authored PR.
Agent review details

How this fits together

Control UI requests enter Gateway identity and authorization owners, which use credential-scoped caches and the GitHub plugin transport to return previews, repository results, and account display facts.

flowchart TD
  A[Control UI request] --> B[Gateway authorization]
  B --> C[Current GitHub identity]
  C --> D[Bounded read cache]
  D --> E[Cached response with freshness]
  D --> F[GitHub transport]
  F --> D
Loading

Technical review

Best possible solution:

Land the shared bounded cache with explicit freshness markers and the retained live-authority and strict-publication checks.

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

Current-main source awaits expired GitHub reads; the supplied controlled-latency comparison demonstrates that delay, but this read-only review ran no target code.

Is this the best way to solve the issue?

A shared cache removes duplicated policy while preserving bounded loads, replacement ordering, failure eviction, identity scoping, and strict verification for publication.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Actions read cache keeps the original intent (6836058: Return expired Actions snapshots while Gateway-owned refreshes run, retaining current authority at delivery.)
  • Preview cache and coalescing changes intended behavior with a stated reason (8b979cc: Share credential-scoped previews while preserving public admission and each reader's live identity; this PR explicitly changes expired reads to marked stale delivery.)
  • Credential verification changes intended behavior with a stated reason (b35d2be: Cache positive token-scoped verification for 60 seconds; this PR permits background renewal only for display consumers and retains strict publication preparation.)
  • Repository search authority changes intended behavior with a stated reason (db01f6d: Keep search host-, credential-, and requester-bound across asynchronous transport; this PR moves refresh lifetime to the Gateway while retaining initiating-requester checks before dispatch.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduction and current-main behavior: The introduced diff replaces separate cache implementations with one factory; current main still waits for expired preview, search, and credential-verification results. (src/infra/stale-while-revalidate-cache.ts:21, 043bab854082)
  • Previous freshness finding resolved: Live personal-status revalidation now preserves prepared.stale, and the added RPC regression expires personal verification while shared verification remains fresh. (src/gateway/github-personal-oauth.ts:123, 043bab854082)
  • Background authority retained: Preview refreshes retain the real prepared identity; the transport revalidates it before dispatch. Supplied traces and negative controls cover unchanged, removed, and rotated managed profiles, plus requester revocation before search redirects and anonymous retries. (src/gateway/server-methods/control-ui.github-preview-refresh.test.ts:28, 043bab854082)
  • Strict publication verification preserved: Stale verification is explicitly selected for display reads; shared publication preparation retains the strict default, and the verifier regression holds a refresh returning HTTP 401 until strict verification settles. (src/agents/github-oauth-client.ts:346, 043bab854082)
  • Approved additive SDK direction: The maintainer-authored change adds one factory to collection-runtime, documents its lifetime and authorization responsibilities, and leaves existing exports and configuration intact. Public docs: docs/plugins/sdk-runtime.md. (docs/plugins/sdk-runtime.md:575, 043bab854082)
  • Exact-head checks: The live REST status read reports success for openclaw/ci-gate, dependency review, and security-sensitive review on the reviewed head; a separate shared OpenClawKit scan remains in progress. (043bab854082)

Likely related people:

  • Peter Steinberger: Raw commit b35d2be adds src/agents/github-oauth-client.ts:29 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b35d2bec33a6; files: src/agents/github-oauth-client.ts)
  • Galin Iliev: Raw commit db01f6d adds src/gateway/project-github-search.ts:175 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: db01f6d520b8; files: src/gateway/project-github-search.ts)

PR surface

Source +80, Tests +580, Docs +22, Other +2. Total +684 across 32 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 21 308 228 +80
Tests 8 627 47 +580
Docs 2 23 1 +22
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 2 +2
Total 32 962 278 +684

Review metrics

Metric Value Why it matters
Public surface 1 SDK factory; 4 optional protocol fields; 0 configuration options The additive contract exposes cache behavior and freshness without changing stored settings or removing existing APIs.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Reduces recurring Control UI latency with limited impact on existing workflows.
  • merge-risk: 🚨 compatibility: Adds a supported Plugin SDK factory and optional response fields; the maintainer-authored direction accepts this additive contract.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-11T14:06:32.816Z sha 4361c61 :: needs real behavior proof before merge. :: [P1] Retain live credential authority during background preview refreshes
  • reviewed 2026-10-11T15:11:47.673Z sha 794afc5 :: needs real behavior proof before merge. :: [P1] Retain live credential authority during background preview refreshes
  • reviewed 2026-10-11T18:51:13.782Z sha d9491c302960e05baa9dcb849283758941ab4c82 :: needs changes before merge. :: none
  • reviewed 2026-10-11T19:09:20.770Z sha 1ae921e :: needs changes before merge. :: [P2] [P2] Preserve personal freshness through status revalidation

Reviewed October 11, 2026, 3:58 PM ET / 19:58 UTC (Revision 5).

@steipete
steipete force-pushed the steipete/perf-micro-github-reads-stale-while-revalidate-20260919 branch 2 times, most recently from 794afc5 to d9491c3 Compare October 11, 2026 18:42
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 11, 2026
Reuse one bounded stale-read cache for Actions, hover previews, repository search, and display-only credential verification. Preserve current reader authority and strict publication verification.
Settle refreshes through promise callbacks after installing the shared entry, preserving synchronous loader admission and error eviction.
Keep credential and requester checks before every background dispatch, and cover profile removal and token rotation through the Gateway RPC.
@steipete
steipete force-pushed the steipete/perf-micro-github-reads-stale-while-revalidate-20260919 branch from d9491c3 to 1ae921e Compare October 11, 2026 19:00
@steipete
steipete merged commit ea4b186 into main Oct 11, 2026
157 checks passed
@steipete
steipete deleted the steipete/perf-micro-github-reads-stale-while-revalidate-20260919 branch October 11, 2026 20:11
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…enclaw#169143)

* perf(github): serve stale Control UI reads during bounded refresh

Reuse one bounded stale-read cache for Actions, hover previews, repository search, and display-only credential verification. Preserve current reader authority and strict publication verification.

* fix(github): keep refresh promise ownership immutable

Settle refreshes through promise callbacks after installing the shared entry, preserving synchronous loader admission and error eviction.

* fix(github): retain read authority during stale refreshes

Keep credential and requester checks before every background dispatch, and cover profile removal and token rotation through the Gateway RPC.

* fix(github): preserve personal account freshness
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation extensions: github GitHub plugin: link previews and reader gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: file-transfer proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts security-sensitive-changed size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant