Skip to content

refactor(gateway): retire the legacy numeric ChatAbortMarker and dead registry surface - #124108

Merged
steipete merged 1 commit into
mainfrom
codex/autoqa-chat-state-dead-surface
Aug 15, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/autoqa-chat-state-dead-surface

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Dead surface in the gateway chat-run state owner, found by the round-5 run-lifecycle lane:

  • The numeric ChatAbortMarker variant was in-process rollout compat for fix(gateway): ignore stale abort markers for fresh chat events #91013 (June 2026). Abort markers are process-local, in-memory only (ChatRunRecord.abortMarker — nothing persists them), so no shipped contract can carry the old shape across a restart; every production producer has gone through createChatAbortMarker (structured) since. Only tests assigned raw numbers, and tests alone are not contracts.
  • Deleting the numeric branch also kills the registeredAtMs timestamp fallback in isChatAbortMarkerCurrent (every entry is stamped by createChatRunEntry, so registeredSequence is always present) — which makes ChatRunEntry.registeredAtMs entirely write-only. Deleted too.
  • ChatRunRegistry.clear had zero callers (restart teardown clears through chatRunState.clear(), which owns the whole store).
  • The standalone createChatRunRegistry/createToolEventRecipientRegistry factories were consumed only by tests; production always goes through createChatRunState(). Tests now use the state-owned instances and the server-chat.ts barrel re-exports are gone.

Why This Change Was Made

Lean-code doctrine: compat is opt-in and this variant never had a contract — it was a live-rollout convenience that became permanent architecture. The sequence comparison is now the sole ordering authority for abort freshness, removing a two-signal inference (sequence-else-timestamp) where one recorded fact belongs.

User Impact

None visible — pure dead-surface removal. Net −32 production LOC.

Evidence

  • node scripts/run-vitest.mjs run over all five touched suites (server-chat.agent-events, gateway-misc, server-maintenance, server-runtime-subscriptions, server-methods) — 462/462 green.
  • Producer sweep: createChatAbortMarker call sites at chat-abort.ts:633, server-close.ts:440, chat-abort-authorization.ts:233 are the only marker producers; grep proves no remaining numeric assignment or registeredAtMs reader outside the deleted code.
  • pnpm tsgo, pnpm check:test-types (they enumerated every stale call site), oxfmt/oxlint clean; autoreview clean (0.99).

Production LOC +8/−40 (net −32); tests +17/−15.

… registry surface

Abort markers are process-local in-memory state (nothing persists them), so
the numeric ChatAbortMarker variant — in-process rollout compat for #91013 —
has been unreachable in production since every producer moved to
createChatAbortMarker. Deleting it also kills the registeredAtMs timestamp
fallback in isChatAbortMarkerCurrent, which makes ChatRunEntry.registeredAtMs
entirely write-only; the sequence comparison is the sole ordering authority.

Dead surface riders (same owner file):
- ChatRunRegistry.clear had zero callers (restart teardown clears through
  chatRunState.clear, which owns the whole store).
- createChatRunRegistry/createToolEventRecipientRegistry standalone factories
  were consumed only by tests; production always goes through
  createChatRunState. Tests now use the state-owned instances, and the
  server-chat barrel re-exports are gone.

Net -32 production LOC; 462 tests across the five touched suites green.
@clawsweeper

clawsweeper Bot commented Aug 15, 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 August 15, 2026 08:34
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 15, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 4:39 AM ET / 08:39 UTC.

ClawSweeper review

What this changes

This PR removes the legacy numeric Gateway abort-marker branch, unused timestamp field, and test-only standalone registry factories while retaining state-owned registries.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this maintainer-owned cleanup open for the remaining exact-head checks and maintainer merge decision. The source sweep found no patch-introduced defect: production uses structured abort markers and the state owner already owns registry cleanup.

Priority: P3
Reviewed head: 62b71ff928977ed52120a3311c8b16a8fd5f0d16
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused and source-consistent, with exact-head checks still needed before merge.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal refactor has no external-contributor proof gate; focused Gateway coverage and exact-head CI are the relevant validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal refactor has no external-contributor proof gate; focused Gateway coverage and exact-head CI are the relevant validation.
Evidence reviewed 8 items Structured-marker owner: The PR makes abort markers structured-only and compares their shared sequence against the registration sequence, retaining suppress-on-marker behavior when no registration exists.
Production writers: Current main’s normal abort path writes markers through createChatAbortMarker; the restart and pre-registration paths do the same.
Shared consumers: Both normal and terminal event projection paths use the same freshness predicate, while timestamp consumers only need the structured marker’s abortedAtMs value.
Findings None None.
Security None None.

How this fits together

Gateway chat-run state keeps in-memory run registrations, abort markers, and tool-recipient state. Abort and shutdown paths write markers; event projection and maintenance use them to decide delivery and cleanup.

flowchart LR
  A[Chat abort or restart] --> B[Gateway chat-run state]
  C[Chat registration] --> B
  B --> D[Sequence freshness decision]
  D --> E[Event projection]
  B --> F[Maintenance and shutdown cleanup]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned Gateway lifecycle cleanup merge once the remaining exact-head checks pass? Merge after green checks: Merge the focused cleanup once the remaining exact-head checks are green.

Why: Repository policy keeps maintainer-authored and maintainer-labeled items open for an explicit maintainer decision even when source review finds no defect.

Before merge

  • Resolve merge risk (P1) - Three exact-head checks were still in progress in the supplied status, so merge validation is not yet complete.
Agent review details

Security

None.

PR surface

Source -32, Tests +2. Total -30 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 2 8 40 -32
Tests 5 17 15 +2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 25 55 -30

Review metrics

Metric Value Why it matters
Production vs test LOC production +8/-40 (net -32); tests +17/-15 (net +2) The cleanup is net-negative in production while tests are updated to exercise the state-owned contract.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Merge after the remaining exact-head checks pass, retaining the single structured in-memory marker contract and state-owned registry lifecycle.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Merge after the remaining exact-head checks pass, retaining the single structured in-memory marker contract and state-owned registry lifecycle.

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

Not applicable: this PR removes internal in-memory compatibility surface rather than fixing a separately reported user-facing failure.

Is this the best way to solve the issue?

Yes: source shows one canonical process-local state owner, all production writers already create structured markers, and consumers preserve the required timestamp and freshness behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a focused internal cleanup with no demonstrated user-visible behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal refactor has no external-contributor proof gate; focused Gateway coverage and exact-head CI are the relevant validation.

Label justifications:

  • P3: This is a focused internal cleanup with no demonstrated user-visible behavior change.
  • 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: This maintainer-authored internal refactor has no external-contributor proof gate; focused Gateway coverage and exact-head CI are the relevant validation.

Evidence

What I checked:

Likely related people:

  • steipete: Current-source blame reaches Peter Steinberger’s recent boundary commit, and this PR continues work in the same Gateway state owner. (role: recent area contributor; confidence: medium; commits: 2e90d6731212, 62b71ff92897; files: src/gateway/server-chat-state.ts, src/gateway/server-connection-state.ts)
  • nxmxbbd: GitHub context identifies this contributor’s merged structured-marker fix as the preceding behavior change. (role: prior related contributor; confidence: medium; commits: cd98f195a709; files: src/gateway/server-chat-state.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for the remaining exact-head checks to complete successfully.

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 merged commit 4fc3756 into main Aug 15, 2026
245 of 254 checks passed
@steipete
steipete deleted the codex/autoqa-chat-state-dead-surface branch August 15, 2026 08:46
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 16, 2026
… registry surface (openclaw#124108)

Abort markers are process-local in-memory state (nothing persists them), so
the numeric ChatAbortMarker variant — in-process rollout compat for openclaw#91013 —
has been unreachable in production since every producer moved to
createChatAbortMarker. Deleting it also kills the registeredAtMs timestamp
fallback in isChatAbortMarkerCurrent, which makes ChatRunEntry.registeredAtMs
entirely write-only; the sequence comparison is the sole ordering authority.

Dead surface riders (same owner file):
- ChatRunRegistry.clear had zero callers (restart teardown clears through
  chatRunState.clear, which owns the whole store).
- createChatRunRegistry/createToolEventRecipientRegistry standalone factories
  were consumed only by tests; production always goes through
  createChatRunState. Tests now use the state-owned instances, and the
  server-chat barrel re-exports are gone.

Net -32 production LOC; 462 tests across the five touched suites green.
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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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