Skip to content

fix(database): merge-commit restack onto #1600 and drop Mongo resume - #1608

Merged
kkopanidis merged 5 commits into
feat/database-realtime-mongofrom
cursor/mongo-1601-no-resume-ab98
Sep 14, 2026
Merged

kkopanidis merged 5 commits into
feat/database-realtime-mongofrom
cursor/mongo-1601-no-resume-ab98

Conversation

@kkopanidis

Copy link
Copy Markdown
Contributor

Merge this PR with “Create a merge commit”. Never squash.

Squash of #1605 and #1606 dropped #1600 (9e6356ef) from history and left #1601 CONFLICTING vs Event Relays. The same squash-merge will do it again. GitHub’s merge commit is what restores ancestry.

Why this exists

#1601 HEAD (47eccc23) is the squash of #1606. The tree matched the restack, but 9e6356ef is not an ancestor. Merge-base vs #1600 is still 6a3aa00e.

This branch:

  1. Merge commit of origin/feat/router-event-relays (9e6356ef) into current feat(database): stream live document updates over admin sockets #1601. Head is strictly ahead of feat(router): add ReBAC-protected event-to-socket relays #1600.
  2. Hermes: keep fix(router): Event Relays interventions (EventBus, Hermes, relay manager) #1604 engine.use + er: + writeBuffer. Graft only socket.io:${port} and register-before-initSockets. Also keep database: recovered rooms, disconnect reason, and executeRecovered fallback to the recovered event so Mongo membership recovery still runs over gRPC.
  3. Strip resume/catch-up: no Redis realtime:resumeToken, no skip-token persist, watch() from now (end of oplog). Leader restart or cursor drop is a gap; clients refetch. Keep membership recovery, ReBAC fail-closed, tickets, $match/$project, leader lock + generation fencing.

Do not merge #1600 or #1601 themselves. Do not force-push feat/database-realtime-mongo or feat/router-event-relays.

Type of change

  • Bugfix (restack ancestry + product: notify-only live updates)
  • Feature
  • This change requires a documentation update

How to merge (humans)

On GitHub: Create a merge commit. Do not “Squash and merge”. Do not rebase-merge.

After this lands, #1601 should be MERGEABLE onto #1600 (still do not land #1601 unless asked).

Open in Web Open in Cursor 

kkopanidis and others added 4 commits September 13, 2026 02:36
…ger) (#1604)

* fix(router): harden event relays for HA and auth lifetime

EventBus uses a single Redis message dispatcher with subscriberId maps,
SIGTERM/SIGINT shutdown, and subscribe-after-ACK. Hermes installs engine
middleware once, skips empty-room namespace broadcasts, demotes hot-path
logs, and re-authenticates recovered /events/ subscriptions. EventRelayManager
gains coalesced periodic reconcile, compiled templates, inbound caps,
TTL-cached emit-time ReBAC, room eviction, backpressure, preview API, and
metrics/docs aligned with the interventions plan.

* fix(router): address #1604 re-review P1 and P2 follow-ups

Recovery re-auth keeps per-user subscription state across disconnect;
emit-time ReBAC distinguishes unavailable vs deny; EventBus drops process
signal handlers and adds subscribeAck; manager subscribes only after Redis
ACK and broadcasts evictRelayIds on refresh; Hermes backpressure uses local
sockets without emit acks; cache is bounded; preview caps sample JSON;
handshake matcher rejects ticket/sid/non-namespace paths; socket middleware
rebind avoids duplicate registration on first sockets enable.

* fix(hermes): restore production tsc for engine middleware chain

Type the Socket.IO engine middleware runner as Express NextFunction so
recursive callbacks match registerGlobalMiddleware. Use Logger.info for
socket trace lines (IConduitLogger has no debug).

* fix(router): import Express Response for socket global middleware

_rebindSocketGlobalMiddlewares passes handlers typed with fetch Response
because Response was not imported from express, failing tsc against Hermes
registerSocketGlobalMiddleware.

* fix(router): quit EventBus on module shutdown signals

Stop event relays and call grpcSdk.bus.quit() from Router.shutdown(),
registered on SIGTERM/SIGINT with process exit so Redis teardown is not
left to SDK signal handlers. Tighten registerGlobalMiddleware typing and
trim handshake helper comment (deslop).

* fix(router): pass-3 recovery, scoped emit, and subscription hygiene

Recovery re-auth keeps membership on Authorization UNAVAILABLE and only
leaves on deny; re-check subscriptions for restored er: rooms via room map.
Prune user subscriptions on disconnect when no other socket holds them.
Scope relay emits to receivers in the target room; use Engine.IO
writeBuffer/writable for backpressure. Drop hot-path Hermes socket info logs.

* fix(router): pass-4 recovery map, backpressure, emit tests

Store relay subs on socket.data; resolve recovered rooms from context and
TTL room map without last-writer userId. Prune room map when unused on
disconnect. Backpressure uses writeBuffer depth only. Add Hermes/router
tests for room-scoped emit and queue metric.

* fix(router): clear eventRelaySubs from socket.data on recovery deny

* fix(router): clear socket.data subs on recovery fail-closed leave
Split validateEventRelayInput into per-field parsers to reduce complexity.
Silence unused-parameter lint in EventBus test FakeRedis stub.
Create a merge commit so #1600 (9e6356e) is an ancestor of this branch.
Do not squash: squash of #1605/#1606 dropped that ancestry and left #1601 CONFLICTING.

# Conflicts:
#	libraries/hermes/src/Socket/Socket.ts
#	libraries/hermes/src/Socket/isSocketHandshake.test.ts
#	libraries/hermes/src/interfaces/Socket.ts

Co-authored-by: Konstantinos Kopanidis <kkopanidis@users.noreply.github.com>
Live updates notify only: change streams start at the end of the oplog.
Do not persist Redis resume tokens or restore on CursorKilled. Leader
restart or cursor drop is a gap; clients refetch.

Co-authored-by: Konstantinos Kopanidis <kkopanidis@users.noreply.github.com>
@kkopanidis
kkopanidis marked this pull request as ready for review September 13, 2026 19:31
Watch is pipeline-only (db.watch(pipeline)). Strip unused change-stream
_id/clusterTime fields and test resume-token fixtures.

Co-authored-by: Konstantinos Kopanidis <kkopanidis@users.noreply.github.com>
@kkopanidis
kkopanidis merged commit 87a9394 into feat/database-realtime-mongo Sep 14, 2026
12 checks passed
@kkopanidis
kkopanidis deleted the cursor/mongo-1601-no-resume-ab98 branch September 14, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants