Skip to content

perf(gateway): avoid repeated GitHub reader identity work - #185685

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-github-preview-options-handlers-20261027
Oct 27, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-github-preview-options-handlers-20261027

Conversation

@steipete

@steipete steipete commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Frequent GitHub preview and publication-options reads repeat identity-selection work even when their cached content is unchanged.

User Impact

Reduces CPU and allocation during GitHub reads without changing response bytes, credential rotation checks, caller revocation, or session visibility.

Why This Change Was Made

Identity selection no longer constructs credential directories that its callers discard. Credential and child-environment consumers resolve their own selected profile path; token rereads remain live. Durable publication-options readers validate and project the current client once per synchronous read instead of twice. Every returned reader retains a live authority check; incognito retains its existing internal guard. No cache, TTL, schema, or public contract changes.

Evidence

Acceptance: identical synthetic preview bytes and upstream/auth counts, fewer unused path/role operations, lower allocation/CPU per owner operation. Base and candidate run in AB/BA order; CPU timing and allocation passes are separate for preview/options. The preview fixture has 10,000 session references, 100 issue/PR links, eight repositories and 40 agents, with a mocked GitHub API and isolated synthetic credentials. It is owner-boundary proof, not a Gateway load test.

Owner workload Base Candidate Change
Identity selection CPU, µs/call 4.617 0.407 −91.2%
Identity selection sampled allocation, B/call 4,462 396 −91.1%
Warm preview wall time, µs/call 1,064 979 −8.0% (context)
Warm preview CPU, µs/call 747.39 701.44 −6.1%
Warm preview sampled allocation, B/call 95,821 79,120 −17.4%
Prepared options reader wall time, µs/call 2.322 1.234 −46.9%
Prepared options reader CPU, µs/call 3.752 1.622 −56.8%
Prepared options reader sampled allocation, B/call 3,019 1,789 −40.7%
Unused profile-path resolutions per warm preview 4 0 Removed
Duplicate role-policy evaluations per durable options read 2 1 Removed

Options: two counterbalanced pairs, 5,000 reads per arm/pass/pair (10,000 per revision in each separate timing/allocation pass). Uses the existing authorization fixture with plain role counters and mocked storage/role-policy lookup; it measures the prepared reader, not full RPC or real database latency. Responses matched in every arm.

Selection: two counterbalanced pairs, five samples × 5,000 calls per arm per pair (50,000 calls per revision). Preview: 3,000 calls per arm, two counterbalanced timing pairs plus one declared extra pair for mixed CPU signs (9,000 calls per revision), and two separate counterbalanced allocation pairs (6,000 per revision). CPU pair deltas were +3.1%, −17.3%, −2.9%; report the modest signed-mean improvement, not the noisier wall-time spread. Preview allocation fell in both pairs. Timing-arm 1-minute host loads (base/candidate) were 45.1/42.4, 42.2/43.3 and 58.0/53.0; the third pair had higher wall time on both sides. Every warm preview retained one live credential revalidation and made zero upstream fetches/JSON parses; serialized response digests matched.

Reproduce with scripts/perf/github-tool-selection-measure.ts and scripts/perf/github-preview-authority-measure.ts; each header documents the optional adjacent frozen owner module for baseline comparisons. The options owner measurement is opt-in in its existing regression test.

The identity regression fails on the base with ten unused state-directory reads for ten assertions (32 other tests pass). The options regression fails on the base with two live role-policy evaluations instead of one (eight other tests pass); it also verifies revocation at all returned reader boundaries. That red wrapper subsequently detected a concurrent edit to the separate identity owner; the options baseline blob remained unchanged. Final options proof completed with wrapper exit 0. An earlier identity green attempt stopped before tests because the source-snapshot verifier observed the options edit; final sources were frozen before the replacement run.

Runtime production delta: +9 lines (+8 identity owner, +1 options owner). The non-test diff is +243 lines including 234 lines of benchmark/inventory tooling; tests add 111 lines, mostly the opt-in options measurement. The small growth separates profile-path preparation from selection without duplicating the selection policy, and explicitly guards the raw session reader after removing the inner duplicate check. Core typecheck, targeted type-aware lint, formatting, export-collision guard, and the nine options tests passed. The session-target file passed 36/37 cases; its first linked-worktree discovery case hit the existing five-second handler deadline during the cold run. That failure is recorded, not masked; the unchanged case also timed out in its targeted candidate replay. The same case passed with the original production owners at base fcfa2def7a0d. This is an unresolved, timing-sensitive local comparison, not a proven inherited failure and not a claimed fix. The five-second production deadline and test assertions were unchanged. All 56 tests across read identity, tool identity and App installation consumers passed, including the new regression. The two script-closure files passed 32 tests. Independent subagent review (autoreview route unavailable): static review through P2, scoped-clean. The final one-line CLI-entry inventory addition was also reviewed clean. The direct review route was refused because it did not match the operator configuration; no configuration was changed.

Scope/gaps: synthetic owner measurements only. The requested fast-path rule applies to these redundant-work deletions; no live Team load or multi-pair Gateway stress campaign was run. Full handler/storage/network latency is not inferred from these numbers. Testbox was not allocated; PR CI supplies broad proof.

CI follow-up: the first run completed 42 jobs successfully and failed only the benchmark scripts typecheck (plus the aggregate gate): an untyped identity array and an overloaded JSON.parse wrapper. The follow-up types the array from the preparation API and preserves parser overloads through a forwarding Proxy. The scripts type lane, targeted lint and benchmark smoke passed locally; independent review of that repair was scoped-clean through P2. No production code or measured warm-path behavior changed.

Final hosted validation: CI run 40476639241 completed successfully on e3f9c0037a85fa315fcd3a233017029efbc5db73 (44 successful jobs, 27 intentionally skipped). Security review also completed successfully with its review job targeting that exact PR head and CI run. The local discovery-timeout comparison above remains an explicit limitation; green selected CI is not presented as a diagnosis of that timeout.

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: M labels Oct 27, 2026
@steipete
steipete marked this pull request as ready for review October 27, 2026 08:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-27T08:55:04.419960Z e3f9c00 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 27, 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: e3f9c0037a85fa315fcd3a233017029efbc5db73
  • 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
Select current GitHub identity facts without deriving unused credential paths, and remove the duplicate synchronous client-policy projection from publication-options reads. Keep credential rotation, caller revocation, and all returned reader guards live. Add work-count regressions and synthetic owner measurements.
@steipete
steipete force-pushed the steipete/perf-github-preview-options-handlers-20261027 branch from cfd8f85 to e3f9c00 Compare October 27, 2026 08:53
@steipete
steipete merged commit 3be098d into main Oct 27, 2026
130 checks passed
@steipete
steipete deleted the steipete/perf-github-preview-options-handlers-20261027 branch October 27, 2026 09:10
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 28, 2026
…85685)

* perf(gateway): avoid repeated GitHub reader identity work

Select current GitHub identity facts without deriving unused credential paths, and remove the duplicate synchronous client-policy projection from publication-options reads. Keep credential rotation, caller revocation, and all returned reader guards live. Add work-count regressions and synthetic owner measurements.

* fix(perf): type GitHub preview benchmark instrumentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. gateway Gateway runtime scripts Repository scripts security-sensitive-changed size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant