Skip to content

fix(gateway): session lists stall during unrelated session writes - #156286

Merged
steipete merged 1 commit into
mainfrom
codex/team-cold-session-readiness
Sep 23, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/team-cold-session-readiness

Conversation

@steipete

@steipete steipete commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session lists can repeatedly discard completed database reads when another session changes during refresh, preventing unchanged rows from making progress.

Related: #155767, #155957.

User Impact

Busy Gateways can refresh unchanged sessions while other sessions are being updated. No configuration, schema, migration, or Doctor changes are needed.

Why This Change Was Made

A keyed publication previously invalidated the entire in-flight row batch. The resident row owner now versions its own database facts, so a changed row is reread without discarding its unchanged siblings. Broad invalidation, session replacement, registry freshness, database custody, permission checks, and complete readiness still use their existing owners.

Evidence

  • Two regressions through the registered sessions.list handler and real read-only workers fail on the original code and pass with the fix: a write outside the captured batch, and a write to one sibling inside it. The changed sibling's current label remains visible.
  • All 46 focused tests pass across worker reads, accepted-fact lifetime, and archived rows. These include membership revocation, same-session replacement, ACP metadata, transcript invalidation, disposal, and physical database replacement.
  • A temporary synthetic workload with 4,000 stored sessions, 1,564 retained subagent records, and 131 projected active runs issues 32 writes to an unrelated session during real worker replies. Previously, all 32 replies left progress at 64 prepared rows. With the fix, progress advances from 64 to 2,048 during those writes. First-request worker completions drop from 220 to 156. This is deterministic work reduction; separate-process timing samples were noisy and did not demonstrate a wall-time improvement.
  • Final worker suite: node scripts/run-vitest.mjs src/gateway/session-row-projection.worker-read.test.ts --maxWorkers=1 passed all 15 cases in 32.78 seconds wall time, including compiler preparation. The two added cases took 865 ms and 869 ms; they extend the existing real-worker fixture without sleeps or polling. The initial three-file run took 86.61 seconds wall time.
  • The full changed-file gate passed: production types, all 25 test-type partitions, lint, dead-export scans, import-cycle checks, and repository guards. The initial run found the existing route-loader type error on main; 813a10e7deb fixed it upstream and is included through a patch-identical rebase.
  • Exact-head CI passed all 130 executing jobs. The 15 worker-read cases total 13.765 seconds of test-body time in CI, including 1.767 seconds for the two new regressions; this excludes import and transform overhead. Independent review and the published ClawSweeper review found no actionable correctness or security issues.

@clawsweeper

clawsweeper Bot commented Sep 23, 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.

@steipete
steipete marked this pull request as ready for review September 23, 2026 06:58
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Sep 23, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 23, 2026, 3:06 AM ET / 07:06 UTC.

ClawSweeper review

What this changes

The Gateway versions each session row’s database facts so unrelated writes no longer discard completed reads, with regression coverage for writes inside and outside the captured batch.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main still discards entire batches after unrelated writes. No actionable correctness or security findings were identified.

Priority: P2
Reviewed head: ac39c12e829e4c843c2704e4fdb0742a19d519cf

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful worker-boundary evidence and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied after-fix observations exercise the resident projection with real database workers under concurrent writes, supported by registered sessions.list race cases. Recorded progress and reduced worker completions demonstrate the changed behavior; no latency improvement is claimed. The new revision is process-local, with no stored-data contract change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied after-fix observations exercise the resident projection with real database workers under concurrent writes, supported by registered sessions.list race cases. Recorded progress and reduced worker completions demonstrate the changed behavior; no latency improvement is claimed. The new revision is process-local, with no stored-data contract change.
Evidence reviewed 8 items Pinned introduced change: Reviewed the merge-base-to-head delta. Only the row projection, its database-fact reader, archive handling, resident records, and worker regression cases are introduced changes; the Codex-related endpoint drift is base-branch work.
Current main still needs the fix: Current main increments databaseRevision for every non-presentation publication, including keyed writes. The original worker reader rejects the entire captured batch when that revision changes.
Row-local acceptance preserves existing fences: The reader captures numeric row revisions before awaiting work and checks them before acceptance, alongside generation, registry, database custody, and broad revision checks. Acquisition, demotion, automation invalidation, and transcript refresh advance the affected row’s revision.
Findings None None.
Security None None.

How this fits together

The Gateway builds session lists from stored session facts and current runtime information. Its resident row projection coordinates worker reads, invalidation, and readiness before authorized results reach clients.

flowchart TD
  A[Session list request] --> B[Resident row projection]
  C[Committed session writes] --> D[Invalidate affected rows]
  D --> B
  B --> E[Read-only database workers]
  E --> F[Check row revision and lifecycle]
  F --> B
  B --> G[Current access checks and list response]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +19, Tests +29. Total +48 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 4 26 7 +19
Tests 1 31 2 +29
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 57 9 +48

Review metrics

Metric Value Why it matters
Recorded worker work 220 → 156 first-request completions The controlled workload demonstrates reduced repeated work; it does not establish a wall-time improvement.
Added regression cost 865 ms and 869 ms The two reported case timings cover real worker races using the existing fixture without sleeps or polling.

Technical review

Best possible solution:

Keep database-fact freshness with each resident row while preserving global invalidation, lifecycle checks, and current authorization at response time.

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

Yes: hold a completed session-row worker reply, commit a different session’s update, and observe main reject the unchanged row’s batch. Source establishes this path; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes. Per-row revisions repair the existing owner’s overly broad invalidation without introducing another cache or weakening full-list readiness.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This addresses session-list refresh stalls under concurrent writes without evidence of a broader runtime outage.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied after-fix observations exercise the resident projection with real database workers under concurrent writes, supported by registered sessions.list race cases. Recorded progress and reduced worker completions demonstrate the changed behavior; no latency improvement is claimed. The new revision is process-local, with no stored-data contract change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied after-fix observations exercise the resident projection with real database workers under concurrent writes, supported by registered sessions.list race cases. Recorded progress and reduced worker completions demonstrate the changed behavior; no latency improvement is claimed. The new revision is process-local, with no stored-data contract change.

Label justifications:

  • P2: This addresses session-list refresh stalls under concurrent writes without evidence of a broader runtime outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied after-fix observations exercise the resident projection with real database workers under concurrent writes, supported by registered sessions.list race cases. Recorded progress and reduced worker completions demonstrate the changed behavior; no latency improvement is claimed. The new revision is process-local, with no stored-data contract change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied after-fix observations exercise the resident projection with real database workers under concurrent writes, supported by registered sessions.list race cases. Recorded progress and reduced worker completions demonstrate the changed behavior; no latency improvement is claimed. The new revision is process-local, with no stored-data contract change.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the merge-base-to-head delta. Only the row projection, its database-fact reader, archive handling, resident records, and worker regression cases are introduced changes; the Codex-related endpoint drift is base-branch work. (ac39c12e829e)
  • Current main still needs the fix: Current main increments databaseRevision for every non-presentation publication, including keyed writes. The original worker reader rejects the entire captured batch when that revision changes. (src/gateway/session-row-projection.ts:283, 5e5f9c275597)
  • Row-local acceptance preserves existing fences: The reader captures numeric row revisions before awaiting work and checks them before acceptance, alongside generation, registry, database custody, and broad revision checks. Acquisition, demotion, automation invalidation, and transcript refresh advance the affected row’s revision. (src/gateway/session-row-projection-read.ts:178, ac39c12e829e)
  • Production-boundary race coverage: The added cases invoke the registered sessions.list handler, hold replies from real database workers, commit another row’s update, and require a response without rereading the unchanged row. They also verify the changed sibling’s current label. Existing cases cover membership revocation and stored ownership changes. (src/gateway/session-row-projection.worker-read.test.ts:278, ac39c12e829e)
  • Recorded after-fix workload: The supplied complete PR body records a synthetic workload using 4,000 stored sessions and real worker replies: during 32 unrelated writes, prepared rows advance from 64 to 2,048 instead of remaining at 64, and first-request worker completions decrease from 220 to 156. It explicitly disclaims a demonstrated wall-time improvement and reports 46 focused passing cases. These observations were reviewed, not independently executed. (ac39c12e829e)
  • Authorization remains at the response boundary: Session lists still await complete projection readiness and then select, authorize, and present using current state. The patch changes fact freshness bookkeeping, without changing principals, grants, durable storage, configuration, or public APIs. (src/gateway/session-utils-list.ts:380, ac39c12e829e)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: 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 23, 2026 07:19
@steipete
steipete merged commit 3ab93b4 into main Sep 23, 2026
274 checks passed
@steipete
steipete deleted the codex/team-cold-session-readiness branch September 23, 2026 07:21
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

vincentkoc added a commit to ycmjbot-bot/openclaw that referenced this pull request Sep 23, 2026
* commit '3ab93b4ea59804b34d02a696382db16dc95189bb': (80 commits)
  fix(gateway): keep session refreshes moving during unrelated writes (openclaw#156286)
  chore(deps): update fs-safe to 0.18.2 (openclaw#156262)
  refactor(plugins): extract ClawHub plugin archives once (openclaw#156246)
  improve(llm-core): avoid unnecessary tool validation sets (openclaw#152066)
  fix(backup): verification accepts archives missing captured databases (openclaw#156211)
  fix: cancel Guest work when its original access is revoked (openclaw#156106)
  fix(test): classify drained legacy migration refusals
  fix(anthropic): finish Opus 5.5 defaults and thinking display (openclaw#156093)
  refactor(agents): share native harness tool execution (openclaw#154217)
  fix(ui): carry typed ownership through short-route resolution
  test(worktrees): accept additive gc result fields (openclaw#156127)
  test(tasks): close sqlite borrowers before registry reload (openclaw#156131)
  chore(autoreview): sync Astra high defaults (openclaw#156175)
  refactor(node-host): await prepared workspace storage (openclaw#149519)
  improve: speed up cold Node test planning (openclaw#156234)
  fix(doctor): avoid slow legacy ownership repair in source checkouts (openclaw#156238)
  improve: speed up native build artifact validation (openclaw#156219)
  fix(ui): preserve short-route resolution ownership
  fix(doctor): name retained session metadata conflicts (openclaw#156162)
  perf(tasks): bound creation selection to matching runs (openclaw#156183)
  ...
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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