Skip to content

fix: reduce repeated work while polling session pull requests - #147373

Merged
steipete merged 3 commits into
mainfrom
codex/pr-reference-read-cache-20260913
Sep 13, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/pr-reference-read-cache-20260913

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes repeated transcript searches and large saved-prompt reads when the Control UI polls unchanged session pull requests, even while its GitHub results are cached.

User Impact

Session PR polling uses less Gateway CPU and memory allocation while preserving the same PR chips, freshness, and GitHub rate-limit behavior. No configuration or migration is required.

Why This Change Was Made

Cache assistant PR references through the existing bounded, watcher-owned cache. The transcript owner supplies a version that includes raw changes, indexing progress, cold archive state, and physical database identity. Concurrent reads share work; failures, unfinished indexing, session changes, and rewrites cannot leave a stale cached result. Metadata reads use the compact session projection and carry the known session ID into canonical message hydration.

Evidence

  • 137 focused reference, transcript search, PR loader, branch, retention, subscription, and repository lifecycle tests pass and cover unchanged/concurrent polling, appends, rewrites during reads, resets, failures, indexing completion, archive restoration, and database replacement/recreation.
  • An isolated benchmark exercises the actual PR loader with 7,500 unrelated matching messages, three target PRs, a roughly 1 MiB saved prompt, and a stubbed GitHub API. Warm median main-thread CPU fell from 15.21 ms to 3.45 ms; wall time fell from 15.28 ms to 3.48 ms. Each unchanged poll went from one transcript search and 6,240,924 decoded prompt bytes to zero of each. Returned PRs were unchanged.
  • Production/test type checks, formatting, lint, dead-export scans, and selected repository guards pass. Independent P2 reviews are clean.
  • These measurements cover this polling path only; they do not establish overall production CPU or heap recovery.

@clawsweeper

clawsweeper Bot commented Sep 13, 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: M labels Sep 13, 2026
@steipete
steipete marked this pull request as ready for review September 13, 2026 20:14
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Sep 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 4:54 PM ET / 20:54 UTC (Revision 2).

ClawSweeper review

What this changes

Caches session PR references and reads compact session metadata to reduce repeated transcript searches and saved-prompt decoding during Control UI polling.

Merge readiness

✅ Ready for maintainer review

This remains a useful performance fix: current main still repeats transcript searches during unchanged polling. No blocking correctness or security defect was found in the introduced changes.

Priority: P2
Reviewed head: 4f97900ea021e6cf2075527c787f9892e056a233

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with meaningful invalidation coverage and bounded benchmark evidence; no actionable blocking defect was found.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored internal optimization is exempt from contributor proof requirements. Its reported loader benchmark uses stubbed GitHub responses and supports the narrow performance claim; it is not live GitHub or whole-Gateway proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored internal optimization is exempt from contributor proof requirements. Its reported loader benchmark uses stubbed GitHub responses and supports the narrow performance claim; it is not live GitHub or whole-Gateway proof.
Evidence reviewed 7 items Current main still performs repeated searches: The fetched main implementation loads full session entries and calls transcript search on every reference request; it has no reference-result cache. The merged PR at #147166 establishes reference discovery, not this polling optimization.
Cache invalidation and ownership: The reference cache uses the existing retained-cache owner, shares pending reads, evicts failures and unfinished indexing, and checks session identity and transcript version after hydration. Search versions include rewrite generation, index progress, archive state, and physical database identity.
Compact metadata preserves required fields: The existing list projection removes skillsSnapshot and systemPromptReport while preserving session and repository metadata. Passing the known session ID uses the existing transcript-target shortcut; canonical message hydration still requests currentOnly reads.
Findings None None.
Security None None.

How this fits together

The Gateway combines PR links from assistant messages with GitHub branch information to populate session PR indicators. This change caches the transcript-derived references while preserving the existing GitHub refresh and subscription lifecycles.

flowchart LR
  A[Session PR polling] --> B[Compact session metadata]
  B --> C[Transcript version check]
  C --> D[Cached PR references]
  C --> E[Search and read assistant messages]
  E --> D
  D --> F[GitHub PR lookup and cache]
  F --> G[Session PR indicators]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +157, Tests +210. Total +367 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 180 23 +157
Tests 4 218 8 +210
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 398 31 +367

Review metrics

Metric Value Why it matters
Production versus test growth Production net +157 lines; tests net +210 lines Production growth implements versioned reuse through the existing cache owner; tests exercise invalidation and reduced repeated work.
Reported polling CPU Warm median 15.21 ms → 3.45 ms The isolated loader benchmark supports the intended optimization but does not measure overall Gateway CPU or heap recovery.

Technical review

Best possible solution:

Keep transcript-version ownership with the transcript subsystem and reuse bounded subscription-owned caching without changing PR selection or GitHub backoff behavior.

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

Yes, from source: repeated PR-loader calls on unchanged sessions still invoke transcript search on current main, even when GitHub facts are cached. Runtime reproduction was not performed in this read-only review.

Is this the best way to solve the issue?

Yes. The patch reuses existing cache and compact-metadata contracts, with owner-supplied invalidation rather than a time-based freshness guess.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This reduces recurring Gateway work for session PR polling with a bounded scope and no reported urgent outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored internal optimization is exempt from contributor proof requirements. Its reported loader benchmark uses stubbed GitHub responses and supports the narrow performance claim; it is not live GitHub or whole-Gateway proof.

Evidence

What I checked:

  • Current main still performs repeated searches: The fetched main implementation loads full session entries and calls transcript search on every reference request; it has no reference-result cache. The merged PR at fix(ui): keep PR bars visible after checkout changes #147166 establishes reference discovery, not this polling optimization. (src/gateway/control-ui-session-pr-references.ts:48, dad7c9d9e2b9)
  • Cache invalidation and ownership: The reference cache uses the existing retained-cache owner, shares pending reads, evicts failures and unfinished indexing, and checks session identity and transcript version after hydration. Search versions include rewrite generation, index progress, archive state, and physical database identity. (src/gateway/control-ui-session-pr-references.ts:103, 4f97900ea021)
  • Compact metadata preserves required fields: The existing list projection removes skillsSnapshot and systemPromptReport while preserving session and repository metadata. Passing the known session ID uses the existing transcript-target shortcut; canonical message hydration still requests currentOnly reads. (src/config/sessions/session-accessor.sqlite-status.ts:40, 4f97900ea021)
  • Re-review continuity: The previous completed review recorded no findings. The only subsequent change establishes a repository-only listener baseline, checks that local checkout pins are released back to it, and retains the final zero-listener assertion after abort. (src/gateway/server.sessions.create.repositories.test.ts:106, 4f97900ea021)
  • Validation and benchmark scope: The supplied PR body reports 137 focused passing tests and an isolated production-loader benchmark with stubbed GitHub responses: warm median CPU decreased from 15.21 ms to 3.45 ms with unchanged returned PRs. Inspected tests cover concurrent reuse, append/rewrite invalidation, read failures, database replacement/recreation, index completion, and archive restoration. These checks were not executed during this read-only review. Downloaded screenshots were inspected and belong to the earlier PR-bar fix, not this performance measurement. (src/gateway/control-ui-session-pr-references.test.ts:78, 4f97900ea021)
  • Feature-history routing: Main history connects Peter Steinberger to the merged reference-discovery implementation and adjacent retained-cache and transcript-lookup improvements. This supports routing independently of authorship of the proposed branch. (src/gateway/control-ui-session-pr-references.ts:77, a2899143b443)

Likely related people:

  • Peter Steinberger: Raw commit a289914 adds src/gateway/control-ui-session-pr-references.ts:43 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a2899143b443; files: src/gateway/control-ui-session-pr-references.ts)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-13T20:40:10.547Z sha 9014d76 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit c747a4c into main Sep 13, 2026
312 of 315 checks passed
@steipete
steipete deleted the codex/pr-reference-read-cache-20260913 branch September 13, 2026 21:19
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to Alix-007/openclaw that referenced this pull request Sep 13, 2026
…1-prep

* commit '912ae8d96e5964dfdcdf419b79613fb941cdf0a8': (350 commits)
  fix: keep workspace preparation responsive during cleanup (openclaw#147358)
  docs: alphabetize donors and sponsors and add Red Hat logo (openclaw#147302)
  fix(plugins): retain update authority through doctor effects (openclaw#144316)
  refactor(qa): share Multipass mount retry lifecycle (openclaw#147084)
  fix(memory): emit one JSON result for command failures (openclaw#147366)
  improve(plugins): speed up cold metadata loading (openclaw#147411)
  fix(sessions): avoid duplicate work after waited child replies (openclaw#147394)
  fix(agents): retain outstanding child results in parent context (openclaw#112623)
  test: preserve native workflow loader selection (openclaw#147403)
  fix: reduce repeated work while polling session pull requests (openclaw#147373)
  test(qa): preserve task cancellation across process replacement (openclaw#147382)
  fix: prevent sidebar refresh storms during session activity (openclaw#147400)
  refactor: simplify skills CLI formatting (openclaw#147368)
  fix: prevent Git checkout certificate failures behind egress proxy (openclaw#147410)
  fix(qa): stop live threads after their process leader exits (openclaw#147386)
  refactor(release): share agent turn retry lifecycle (openclaw#147076)
  fix(ui): keep uploaded images aligned with their prompts (openclaw#147389)
  fix(fs): guard skill reads and bound worker bundle staging (openclaw#147336)
  fix(ci): restore Linux service ownership fixtures (openclaw#147398)
  fix(plugins): preserve manifest permissions when building plugins (openclaw#147393)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
…aw#147373)

* fix: reduce repeated work while polling session pull requests

* test: stabilize session PR reference fixtures

* test: verify PR cache listener cleanup against its baseline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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