Skip to content

fix(gateway): share GitHub options preparation during reconnects - #173589

Merged
steipete merged 4 commits into
mainfrom
steipete/perf-micro-github-options-timeouts-20260919
Oct 16, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/perf-micro-github-options-timeouts-20260919

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Concurrent sessions.github.options calls after reconnect independently prepare the same session, then shared-receipt lookup prepares it again. These ordered metadata reads queue behind session discovery and cause options timeouts. Related: #173534.

Change and Ownership

Share only pending durable-session preparation, keyed by published configuration identity/revision, requested agent, and session key. Each caller keeps independent cancellation, live permissions, and disposal; the last waiter releases the existing retained predicate. Incognito actors keep their caller-owned path. Settlement removes the pending entry: there is no completed cache, TTL, retry, schema change, or new configuration.

Carry that prepared read into receipt lookup instead of acquiring the session again. Both options and publication actions reuse their held owner. Standalone receipt/status reads still acquire their own owner; shared-state observation remains on readers. Identity, workspace, and disclosure checks still run around asynchronous observation. Identical durable observations share only their pending worker result. Publication, worktree-registry, repository-workspace, and database lifecycle owners clear pending entries on change; settlement evicts the entry. Private actors and maintenance contexts retain separate reads.

Production delta against the task base: +120 lines; tests: +158 lines. Growth preserves independent cancellation/release and coalesces two distinct pending operations without keeping completed snapshots. The 150-reader regression demonstrates why removing repeated acquisition also requires coalescing the resulting observation fanout. Removing ordered acquisition would lose the snapshot/invalidation boundary. The simplification removes repeated acquisition rather than layering another snapshot cache beside the existing owner.

Reproduction and Measurement

The exact #173534 parent (086fc5ca52d2) and merge (6574349e132d) each use freshly generated synthetic state: 5,000 sessions, 6,000 retained runs, 200 approvals, 100 cron jobs, 12 projects, and 1,500 MiB logical transcript text (4.64 GB agent database). The existing restart driver pairs 150 clients, interrupts 30 held model requests, and measures five minutes of reconnect polling. Same fixture shape and command for every variant; authorized isolated Linux sandbox with CPU/memory/I/O limits and loopback ports. No production state is used.

Version Options requests Timeouts Successful p99 All-attempt p99 Publication writer requests
Exact parent 8,047 138 236.90 ms 5,005.06 ms 23,908
#173534 merge 8,055 126 257.03 ms 5,004.07 ms 1
This fix (3403dc4d8fa8) 8,100 0 1,772.35 ms 1,772.35 ms 1

All baseline timeouts occur during the initial burst. This matched pair does not reproduce the earlier 2→55 count; the earlier report used a different baseline. It does reproduce duplicate ordered session preparation. Correlating request trace IDs with slow agent reservations finds 173 slow ordered reads for the merge run: 989,289 ms cumulative queue wait versus 39 ms execution (maximum 7,796 ms queue versus 3 ms execution). This identifies preparation queuing, not execution in the shared-state reader pool. An intermediate sharing-only run still had 111 timeouts; tracing it exposed the redundant receipt preparation removed in the final change.

The final burst has zero timeouts and zero capacity failures. All 150 clients connect. All-attempt p99 improves 2.82× versus the merge; successful-only p99 includes formerly failing slow startup requests and must not be interpreted without the timeout count. Options-attributed slow ordered reservations fall from 173 to 3, with cumulative queue wait 989,289 → 5,656 ms. A borrowed-session-only intermediate run exposed reader fanout (54 timeouts plus 34 capacity failures); it is not the final candidate. The 150-reader regression reproduced 150 observation submissions before coalescing, then one afterward, with new reads after publication and workspace-owner changes.

Secondary Latency Control

The original driver sleeps after each response. Shared completion therefore clusters later polls: median in-flight sessions.list calls at arrival rise from 5 on the merge to 21 with the fix; requests per occupied 10 ms bin rise 7.01 → 31.19. Other RPCs have zero errors, but their original-run p99 rises: list 76.51 → 283.33 ms; catalog 81.27 → 289.31 ms; projects 81.81 → 289.76 ms. Warm main-thread CPU falls 605.49 → 485.68 ms per approximately five-second sample (~20%).

An additional two-minute fixed-cadence control compared the exact parent and fix using their already-recovered synthetic fixtures. It staggers 150 clients evenly over the existing five-second poll interval and samples the final minute. This isolates per-request latency from response-driven cohort synchronization; it is separate from the original five-minute reconnect result above. Each method completed 1,799 requests in the sampled minute, with zero errors on both versions:

Method Parent p50 / p99 Fix p50 / p99
sessions.list 0.75 / 4.32 ms 0.68 / 4.28 ms
sessions.catalog.list 3.04 / 7.25 ms 2.31 / 6.79 ms
projects.list 3.74 / 8.17 ms 3.37 / 8.28 ms
sessions.github.options 39.32 / 56.35 ms 39.76 / 49.23 ms

This control finds no meaningful per-request regression; the 0.11 ms projects p99 difference and 0.44 ms options median difference are noise-scale in a single paired run. The original driver remains the reconnect proof. Its higher sibling latency is consistent with the measured response-driven synchronization, not additional CPU work. These are single paired samples, not statistical confidence intervals.

Proof and Review

Focused regression coverage proves one preparation for overlapping readers, independent cancellation/disposal, archive invalidation, fresh subsequent reads, and config revision separation even when the same config object is republished. The original sharing and revision tests failed before their respective fixes. A real retained-session regression fails when borrowed custody is ignored and passes when released custody is rejected.

Focused checks: authorization 8 passed; shared receipt reads 35 passed, plus the expanded workspace-invalidation regression passed after review; RPC/actions 47 passed; session lookup 14 passed. CI caught a stale three-argument mock expectation after adding the prepared-read argument; the failing file passes after repair. Changed-file oxfmt, core lint, and diff checks passed. An initial test import loaded production code before harness mocks; moving the import inside the test corrected all six fixture failures. One intermediate test invocation rejected source formatting changes during its compiled-worker run; final verification uses stable source.

PR CI owns broad validation; no Testbox/Crabbox was allocated and no broad local suite/typecheck/build was invoked. Focused test commands perform their normal worker-artifact preparation. Earlier authorization-only head CI passed; the borrowed-read head exposed the alias-routing mock expectation above. Exact-head CI run 38833983805 passed on 3403dc4d8fa80ab24910d22453217f6542faa4be, including broad tests, types, and lint. The required CI gate is checked before merge.

Independent subagent review (autoreview route unavailable): no actionable P0/P1/P2 findings, including review of the config-revision repair and borrowed snapshot lifetime. The autoreview helper refused the provider route because it did not match operator configuration; configuration was not changed.

@clawsweeper

clawsweeper Bot commented Oct 16, 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 gateway Gateway runtime size: S labels Oct 16, 2026
@steipete
steipete marked this pull request as ready for review October 16, 2026 00:29
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Contributor

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-16T01:17:16.162964Z 3403dc4 New commits
ℹ️ 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.

@github-actions

github-actions Bot commented Oct 16, 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: 3403dc4d8fa80ab24910d22453217f6542faa4be
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/server-methods/github-personal-authorization.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

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

Copy link
Copy Markdown
Contributor

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: 4bd57923a1

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

@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR shares pending GitHub publication metadata preparation across overlapping requests while preserving caller-specific authorization and cleanup.

Example: Three overlapping requests ask for publication options for session main.

  • Before: Each request independently prepares the same session metadata.
  • After: The requests share one pending preparation, and cancelling or releasing one reader leaves the others independent.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-consistent, with useful regression coverage and green CI; its intended performance benefit is not yet measured.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor-proof gate does not apply to this maintainer-authored PR; supplied evidence covers focused tests and CI, while the author's explicitly required reconnect benchmark has no after-fix results yet.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: GitHub publication options can time out when many clients reconnect concurrently.
Reason: The maintainer-authored direction targets a measured workflow problem with bounded sharing and no new user-facing contract.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses repeated preparation still present on main, and no actionable introduced defect was found.

Priority: P2
Reviewed head: e53725608e2f72372e75172b28a34c56ff348ea6

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The requested real-Gateway 150-client reconnect comparison remains pending; it must establish timeout counts, p99 latency, and writer metrics for this fix against the stated baselines.
Agent review details

How this fits together

Gateway publication-options and status RPCs combine session metadata, caller permissions, GitHub identity, and publication receipts into an authorized response.

flowchart TD
  A[Control UI requests] --> B[Gateway RPC handlers]
  B --> C[Pending session preparation]
  C --> D[Session read worker]
  E[Committed metadata receipts] --> C
  C --> F[Caller authorization and visibility]
  F --> G[Publication options response]
Loading

Technical review

Best possible solution:

Retain pending-only sharing around the existing metadata owner, preserving independent authorization and receipt-driven invalidation.

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

Main visibly performs separate preparations for overlapping requests; the reported regression fails before sharing and passes afterward, but this review ran no target code.

Is this the best way to solve the issue?

The patch addresses duplicate preparation at its existing owner without caching completed results or sharing caller permissions, and the added tests protect meaningful lifetime contracts.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Worker-based session preparation and metadata custody keeps the original intent (cbc53ac: Move session reads into workers while retaining prepared facts through dependent effects and updating them through committed receipts.)
  • Publication-options performance and live authorization keeps the original intent (b35d2be: Avoid redundant publication-options discovery while preserving live session and authority checks.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +68, Tests +81. Total +149 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 74 6 +68
Tests 1 84 3 +81
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 158 9 +149

Review metrics

Metric Value Why it matters
Production versus test LOC Production +68 net; tests +81 net Production growth implements pending-flight ownership and independent cleanup; tests cover cancellation, release, invalidation, and config publication.

Labels

Label changes:

  • add P2: The change targets transient GitHub publication-options latency during reconnect bursts, with limited impact outside that workflow.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The change targets transient GitHub publication-options latency during reconnect bursts, with limited impact outside that workflow.
  • 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.

Rank-up moves

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

  • Publish the pending reconnect comparison and confirm that it meets the author's stated regression target before landing.

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.

Reviewed October 15, 2026, 8:56 PM ET / October 16, 2026, 00:56 UTC.

@steipete
steipete merged commit 4cf3df6 into main Oct 16, 2026
131 of 133 checks passed
@steipete
steipete deleted the steipete/perf-micro-github-options-timeouts-20260919 branch October 16, 2026 01:30
vincentkoc added a commit that referenced this pull request Oct 16, 2026
* commit '56c315156f4542f197a2b7f727681ba3f41c21b5': (23 commits)
  fix(ui): remove stale Lit cleanup from model catalog tests
  refactor(tests): consolidate iMessage discovery checks (#173624)
  fix(auto-reply): retire older collect cancellation after admission
  fix(memory): avoid rebuilding initially empty indexes after restart (#173622)
  fix(test): preserve subprocess runtime identity (#173446)
  perf(sessions): batch transcript index reconciliation (#173620)
  fix(gateway): share GitHub options preparation during reconnects (#173589)
  perf(control-ui): open the composer model picker without list-wide work (#173275)
  fix: finish compile-cache cleanup after short CLI commands exit (#173603)
  refactor(ui): finish native shell rendering (#171554)
  fix: preserve standalone CLI profiles and settle Doctor shutdown (#173154)
  refactor: centralize agent memory host typing (#173619)
  fix: camera fallback picker opens away from the attachment button (#173618)
  refactor: deduplicate existing CI runner routing with YAML anchors (#172670)
  fix(ai): preserve multiline Google replies and report malformed streams (#173612)
  refactor(tests): remove duplicate speech policy test (#173606)
  refactor(ui): simplify page rendering and derivations (#173608)
  fix(release): Linux channel promotion fails after a withdrawn Windows companion (#173615)
  fix(update): wait for native Gateway ownership before restarting (#173588)
  test(sessions): admit schema probe fixture writes behind maintenance
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…nclaw#173589)

* fix(gateway): share GitHub options preparation during reconnects

* fix(gateway): isolate options preparation across config revisions

* perf(gateway): reuse prepared sessions for publication receipt reads

* perf(gateway): coalesce pending publication observations
vincentkoc added a commit that referenced this pull request Oct 16, 2026
* fix(ci): share the iOS screenshot build

* fix(ci): preserve the screenshot artifact container on download

* merge: integrate main for iOS screenshot workflow conflicts

* style(ci): format the combined screenshot evidence changes

* docs(ci): name the combined screenshot capture

* fix(ios): expose screenshot simulator creation errors

* Merge main at 56c3151 to include the UI test cleanup fix

* commit '56c315156f4542f197a2b7f727681ba3f41c21b5': (23 commits)
  fix(ui): remove stale Lit cleanup from model catalog tests
  refactor(tests): consolidate iMessage discovery checks (#173624)
  fix(auto-reply): retire older collect cancellation after admission
  fix(memory): avoid rebuilding initially empty indexes after restart (#173622)
  fix(test): preserve subprocess runtime identity (#173446)
  perf(sessions): batch transcript index reconciliation (#173620)
  fix(gateway): share GitHub options preparation during reconnects (#173589)
  perf(control-ui): open the composer model picker without list-wide work (#173275)
  fix: finish compile-cache cleanup after short CLI commands exit (#173603)
  refactor(ui): finish native shell rendering (#171554)
  fix: preserve standalone CLI profiles and settle Doctor shutdown (#173154)
  refactor: centralize agent memory host typing (#173619)
  fix: camera fallback picker opens away from the attachment button (#173618)
  refactor: deduplicate existing CI runner routing with YAML anchors (#172670)
  fix(ai): preserve multiline Google replies and report malformed streams (#173612)
  refactor(tests): remove duplicate speech policy test (#173606)
  refactor(ui): simplify page rendering and derivations (#173608)
  fix(release): Linux channel promotion fails after a withdrawn Windows companion (#173615)
  fix(update): wait for native Gateway ownership before restarting (#173588)
  test(sessions): admit schema probe fixture writes behind maintenance
  ...

Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
* fix(ci): share the iOS screenshot build

* fix(ci): preserve the screenshot artifact container on download

* merge: integrate main for iOS screenshot workflow conflicts

* style(ci): format the combined screenshot evidence changes

* docs(ci): name the combined screenshot capture

* fix(ios): expose screenshot simulator creation errors

* Merge main at a11e38b to include the UI test cleanup fix

* commit 'a11e38b8bb1eb58aaf392a0eab458dbb47aad30f': (23 commits)
  fix(ui): remove stale Lit cleanup from model catalog tests
  refactor(tests): consolidate iMessage discovery checks (openclaw#173624)
  fix(auto-reply): retire older collect cancellation after admission
  fix(memory): avoid rebuilding initially empty indexes after restart (openclaw#173622)
  fix(test): preserve subprocess runtime identity (openclaw#173446)
  perf(sessions): batch transcript index reconciliation (openclaw#173620)
  fix(gateway): share GitHub options preparation during reconnects (openclaw#173589)
  perf(control-ui): open the composer model picker without list-wide work (openclaw#173275)
  fix: finish compile-cache cleanup after short CLI commands exit (openclaw#173603)
  refactor(ui): finish native shell rendering (openclaw#171554)
  fix: preserve standalone CLI profiles and settle Doctor shutdown (openclaw#173154)
  refactor: centralize agent memory host typing (openclaw#173619)
  fix: camera fallback picker opens away from the attachment button (openclaw#173618)
  refactor: deduplicate existing CI runner routing with YAML anchors (openclaw#172670)
  fix(ai): preserve multiline Google replies and report malformed streams (openclaw#173612)
  refactor(tests): remove duplicate speech policy test (openclaw#173606)
  refactor(ui): simplify page rendering and derivations (openclaw#173608)
  fix(release): Linux channel promotion fails after a withdrawn Windows companion (openclaw#173615)
  fix(update): wait for native Gateway ownership before restarting (openclaw#173588)
  test(sessions): admit schema probe fixture writes behind maintenance
  ...

Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant