Skip to content

fix(sessions): release PR caches when pending viewers leave - #157776

Merged
steipete merged 1 commit into
mainfrom
codex/team-pr-cache-retirement
Sep 25, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/team-pr-cache-retirement

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

A pending PR-panel subscription can keep its shared cache alive after the viewer disconnects or switches to another session, until the old preparation eventually finishes.

User Impact

Abandoned subscriptions release their PR cache immediately. A replacement that still watches the same session keeps the shared cache and avoids a redundant fetch.

Why This Change Was Made

Keep retained cache keys with each replacement generation so disconnect, supersession, and completion can retire their ownership. Install the successor’s interest before retiring its predecessor. This follows up on @galiniliev’s #156121 and preserves its generation-bound refresh acknowledgments, per-viewer delivery, and authorization checks.

Evidence

  • On the original main commit, the disconnect and different-session regression cases fail because the cache signal remains active; the same-session case passes.
  • Both complete subscription test files pass: 57 cases, 36.49 seconds command wall time (28.73 seconds Vitest, including cold compilation). The three new cases use deferred promises and fake timers, with no added process boot or real-time wait.
  • Targeted typed lint passes in 25.36 seconds; formatting and staged diff checks pass.
  • Independent P0–P2 review found no actionable findings. Hosted CI is pending publication.

Retain the keys owned by each pending replacement so disconnect and
supersession retire abandoned cache interest immediately. Install successor
interest before retiring the previous generation, and release completed
generation tokens. Preserve per-viewer delivery and forced-refresh generations.

Follow-up to #156121. Original production fails the disconnect and
other-session controls; same-session reuse passes. All 57 owner and sibling
cases, targeted typed lint, formatting, and independent review pass.
@clawsweeper

clawsweeper Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review September 25, 2026 00:53
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 24, 2026, 9:00 PM ET / September 25, 2026, 01:00 UTC.

ClawSweeper review

What this changes

The Gateway now releases shared pull-request cache interest when a preparing Control UI viewer disconnects or changes sessions, while preserving it for a same-session replacement.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still has the pending-viewer cache lifetime gap, and the earlier merged session-read PR did not resolve it. This is a distinct, focused fix with no concrete correctness finding from source review.

Priority: P2
Reviewed head: 9fbcaa2aa199e83a153101e6559b89ea99920972

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused lifecycle repair has meaningful baseline regression controls and no identified correctness or security defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository-admin author's internal Gateway cache fix is exempt from the external-contributor real-setup gate. The PR reports baseline failures and 57 passing scoped cases through an injected subscription owner; no production WebSocket run is claimed. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository-admin author's internal Gateway cache fix is exempt from the external-contributor real-setup gate. The PR reports baseline failures and 57 passing scoped cases through an injected subscription owner; no production WebSocket run is claimed. No stored-data contract changes.
Evidence reviewed 8 items Current-main lifetime gap: The current-main unsubscribe path clears the replacement generation and established memberships, but does not immediately retire cache interest held by a still-preparing replacement.
Introduced repair: The introduced patch records retained keys per replacement generation, transfers same-key interest before retiring a predecessor, and retires retained keys on unsubscribe.
Regression controls: Three parameterized cases hold viewer preparation open and check disconnect, different-session replacement, and same-session cache reuse. The PR body reports that the first two fail on its original main baseline and that 57 scoped cases pass after the change; this review did not execute them.
Findings None None.
Security None None.

How this fits together

The Control UI sends watched session keys to the Gateway. The Gateway authorizes each viewer, shares GitHub pull-request reads across viewers of a session, and sends updated status back to connected viewers.

flowchart LR
  A[Control UI viewer] --> B[Subscribe request]
  B --> C[Authorized session read]
  C --> D{Viewer still watching?}
  D -->|Yes| E[Shared PR cache]
  D -->|No| F[Release cache interest]
  E --> G[PR status update]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +13, Tests +66. Total +79 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 24 11 +13
Tests 1 66 0 +66
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 90 11 +79

Review metrics

Metric Value Why it matters
Production and test growth production +24/−11 lines; tests +66/−0 lines The bounded lifetime-state change has three regression cases covering the viewer transitions it changes.

Technical review

Best possible solution:

Keep cache retention tied to the union of live, authorized viewers throughout preparation, replacement, delivery, and disconnect.

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

Yes. The current-main unsubscribe path and the added deferred-preparation controls give a specific reproduction path; the PR reports baseline failures, but this read-only review did not rerun them.

Is this the best way to solve the issue?

Yes. The existing Gateway subscription owner already manages viewer membership and cache lifetime, making it the narrowest place to retire abandoned interest.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 281967681fd0.

Labels

Label changes:

  • add P2: A pending viewer can retain shared cache work after leaving, but the reported impact is limited to this Control UI subscription path.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: A pending viewer can retain shared cache work after leaving, but the reported impact is limited to this Control UI subscription path.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • galiniliev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Shakker: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

@steipete
steipete enabled auto-merge (squash) September 25, 2026 01:07
@steipete
steipete merged commit 9b0a71e into main Sep 25, 2026
261 of 263 checks passed
@steipete
steipete deleted the codex/team-pr-cache-retirement branch September 25, 2026 02:13
vincentkoc added a commit that referenced this pull request Sep 25, 2026
* commit '05edd36e124dc376f63475256f45e82ec437412c': (30 commits)
  refactor(matrix): reuse bounded direct-room cache insertion (#157775)
  fix: preserve channel-owner revocation across recovery (#157709)
  fix(ci): stop blocking CI during release validation (#157757)
  refactor(tlon): remove unreachable DM summary branches (#157789)
  chore: speed up worktree recovery tests with Bun (#157674)
  fix(sessions): release PR caches when pending viewers leave (#157776)
  refactor(twitch): reuse setup account selection (#157787)
  test: skip empty task ledger resets in cron fixtures (#157767)
  perf: reduce gateway and state test startup (#157711)
  fix: preserve maintenance leases during slow heartbeat renewal (#157696)
  fix(channels): match non-TTY setup advice to registered flags (#157551)
  fix: keep failed update report uploads in the CLI (#156633)
  fix: preserve rejected settings reason when opening config (#157731)
  test(update): load real filesystem dependencies in swap fixture
  fix(ci): prevent Security Review checkout retry collisions (#157652)
  fix(ci): recover interrupted Security Review response bodies (#157651)
  test(ui): capture live operator authority in guest question fixture
  refactor(agents): deslop runners, harness and recovery (#157294)
  fix(auth): preserve Copilot tenant credentials during Doctor repair (#139131)
  refactor(msteams): share stored service URL validation (#157706)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
…#157776)

Retain the keys owned by each pending replacement so disconnect and
supersession retire abandoned cache interest immediately. Install successor
interest before retiring the previous generation, and release completed
generation tokens. Preserve per-viewer delivery and forced-refresh generations.

Follow-up to openclaw#156121. Original production fails the disconnect and
other-session controls; same-session reuse passes. All 57 owner and sibling
cases, targeted typed lint, formatting, and independent review pass.
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant