Skip to content

refactor(gateway): unify chat run state - #113157

Merged
steipete merged 2 commits into
mainfrom
steipete/simplify-w4-chat-run-record
Jul 23, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/simplify-w4-chat-run-record

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway chat runs stored one logical run across parallel maps for buffers, plan state, timestamps, abort markers, registration queues, and tool-event recipients. That made lifecycle cleanup easy to miss on one surface and forced the same state bundle through request, maintenance, restart, and local-runtime boundaries.

Why This Change Was Made

This replaces the parallel storage with one insertion-ordered Map<runId, ChatRunRecord>. Registration queues and tool recipients share the same record owner, transient projection cleanup is centralized, and abort tombstones plus FIFO/recipient lifetimes remain intact. Protocol event and persistence shapes are unchanged.

User Impact

There is no user-visible behavior change. Gateway chat state now has one lifecycle owner, reducing the risk of stale buffers, incomplete cleanup, or mismatched per-run metadata during aborts, reloads, and restart shutdown.

Evidence

  • Before/after exact chat and agent projection suite: src/gateway/server-chat.agent-events.test.ts 129/129 passed on both implementations.
  • Cohesive lifecycle and deterministic ordering coverage: src/gateway/server-chat-state.test.ts 10/10 passed.
  • Abort, restart, maintenance, and reload handlers: 375/375 passed.
  • Gateway chat suites: mocked 89/89; live gateway 43/43.
  • Blacksmith Testbox check:changed passed for core + core tests, including production/test typecheck, format, lint, max-lines, import cycles, and database-first guards: https://github.com/openclaw/openclaw/actions/runs/30047457810
  • Fresh Codex autoreview: no accepted/actionable findings; patch correct (0.91 confidence).

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XL maintainer Maintainer-authored PR labels Jul 23, 2026
@steipete steipete self-assigned this Jul 23, 2026
@steipete
steipete marked this pull request as ready for review July 23, 2026 22:08
@steipete
steipete requested a review from a team as a code owner July 23, 2026 22:08
@steipete
steipete merged commit 7cbd247 into main Jul 23, 2026
117 checks passed
@steipete
steipete deleted the steipete/simplify-w4-chat-run-record branch July 23, 2026 22:45
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 24, 2026
* refactor(gateway): unify chat run state

* test(gateway): align chat run fixtures
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 size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant