Repository navigation
Feature/enhance realtime workflow - #726
Conversation
- Introduced SyncHub for ordered delivery of project change logs. - Added support for syncing changes through a new "sync:join" event. - Implemented logic to handle missed changes and deliver them in batches. - Enhanced socket management to track which projects each socket is syncing. - Added tests to ensure correct behavior of the SyncHub and its interactions. - Updated permissions to include new project-related events and namespaces. - Refactored existing code to integrate with the new sync functionality.
…egration - Add CollabCluster for managing collaborative editing sessions across multiple replicas. - Introduce ValkeyLeases and ValkeyBus for lease management and message passing using Redis. - Enhance CollabHub to support room authority checks and room lifecycle management. - Update configuration to support collaborative editing features, including replica identification. - Modify socket server to integrate collaborative editing functionality, allowing for room ownership and message routing. - Implement tests for event registry and sync functionality to ensure proper operation of collaborative features.
There was a problem hiding this comment.
Important
Two findings with concrete fallout before merge: an unbounded retry loop in SyncHub.pump that can wedge a project's feed and hammer a failing permissions endpoint, and the web client discarding its cursor so a refused or restarted sync join loses the gap it was replaying. Two smaller notes inline.
Reviewed changes
Reviewed the full 114-file diff at cf4e1b1b end to end: the API change log and outbox, the realtime sync hub and replica routing, the web sync client and cache rules, plus the migration and tests.
- Resumable change feed — a per-project Valkey Stream filled by one Lua script (seq + epoch), read back by a new
SyncHubthat servessync:join/sync:changes/sync:reset/sync:heartbeat. - Authorization — every change in the feed is checked with the same IAM question as the legacy path, and what an account may not read arrives as
{seq, skip}so its sequence stays gapless. - Cache patching — snapshots patch task/sprint rows in place and lists refetch only when a field a list can filter or group on changed; the old if-chain becomes an ordered rule table.
- Client cursor and first-join race —
ProjectSynckeeps epoch/cursor per project,X-Change-Seqseeds a first join, andX-Client-Op-Idlets a client skip its own echo. - Transactional outbox and row versions — migration 000083 adds
versiontriggers andchange_outbox, a reconciler re-announces lost changes, and task/sprintPATCHhonoursIf-Matchwith 412. - Cross-replica collaboration — per-room Valkey leases plus a per-replica bus so the editors of one document can sit on different replicas.
- Supporting work — generated event registry, IAM epoch backstop, Helm gate for
replicaCount > 1, docs and realtime e2e specs.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the 8-file delta since the prior pullfrog review at cf4e1b1b: the four fixes for the findings raised there, plus the accompanying tests.
- Stopped the sync pump from spinning —
SyncHub.pumpsnapshots each subscriber's cursor before reading a batch and returns when no delivery moved one, so a failing access check costs one read per nudge or poll instead of an unbounded loop that held the project's queue; a new 450-entry backlog test asserts the bounded read count and the clean catch-up. - Kept the client cursor —
leaveProjectno longer deletes the per-project sync state (it is cleared on disconnect/sign-out), so re-entering a project resumes from its cursor; a refusedsync:joinnow fires the reset listeners when the client had a cursor, so the missed window is refetched instead of silently dropped. - Seeded the cursor from the lowest head —
observeChangeHeadkeeps the lowest seq for the same epoch regardless of response arrival order, with both orders covered. - Removed the row serialisation from the outbox trigger — migration 000083 splits capture into
capture_versioned_changefortasks/sprintsandcapture_unversioned_changefordocuments, reading the columns directly instead of buildingto_jsonb(NEW)on every write. - Test hygiene — the affected Go tests now use
httptest.NewRequestWithContextinstead of the deprecated constructor; the touched handler and middleware packages pass locally.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
…rotocol documentation
There was a problem hiding this comment.
Important
The reconciler does not repair a lost hard delete: announced compares versions without looking at the row's operation, so a deleted sprint whose sprint.deleted announcement was lost is treated as already announced.
Reviewed changes
Reviewed the 14-file delta since the prior pullfrog review at 65beaff: outbox pruning and delete handling, the monotonic last-logged index, dropping documents from the outbox, the outbox row ordering, the change-head read timeout, and the accompanying tests and docs.
- Bounded the outbox —
Prunedeletes rows older than the change log's retention andTickcalls it at most once a minute, so the table stays bounded even while Valkey is unreachable. - Made the last-logged index monotonic — the append script keeps an entity's highest row version so an out-of-order announcement cannot lower it, with a test covering 6→5, the unknown version and a delete.
- Removed documents from the outbox — the doc trigger, loader, entity constant and repair branch are gone, and the migration and README record why docs are left to the docs pull/push work.
- Chose the newest outbox row by id —
reconcilenow uses the highest row id, the orderClaimreads, instead of comparingcreated_at. - Capped the change-head read — the middleware gives the Valkey lookup 50 ms and serves the request unstamped when the log is slower, with a slow-reader test.
- Covered the access-cache burst — a new realtime test asserts one permissions request per account for a 200-change burst and none once warm.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta since the prior pullfrog review at cfcdf37b: the hard-delete repair fix, the change-head comment tidy, and their tests.
- Repaired a lost hard delete —
announcednow treats adeleteoutbox row as announced only when a delete was logged, so a sprint hard delete whosesprint.deletednever went out is re-announced instead of skipped; a unit case covers the pre-delete version, and the existing integration test already announces a missing entity as<entity>.deleted. - Tidied the change-head docs — the timeout comment is back above
changeHeadTimeoutand each header constant carries its own doc. - Test hygiene — the change-head test uses
httptest.NewRequestWithContext.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Summary
Agent, API and other-user changes now reach the open web app as small, ordered changes instead of "refetch everything". The design follows collaborative editing (Yjs): the update is the delta, a reconnect resumes from where the client was, and the lifecycle is explicit.
The new sync protocol is opt-in (web flag
localStorage["paca.realtime.sync"]="1"/VITE_REALTIME_SYNC=true, serverSYNC_ENABLED). The plaineventpath stays in place.What changed
Resumable change feed
sync:joinand get ordered, gaplesssync:changesbatches,sync:resetwhen history cannot be replayed, and heartbeats. A client resumes from its cursor after any absence.sync-engine.ts(cursor/epoch rules),cache-patch.ts(patch the React Query cache from the snapshot; refetch lists only when a filter/sort/group field changed), and an ordered rule table (project-event-rules.ts).Known gaps closed
tasks/sprintswritechange_outboxin the same transaction; a reconciler announces changes whose announcement was lost, comparing rowversionwith the last logged version.If-Match:tasksandsprintscarry aversion(migration 000083).PATCHwithIf-Matchanswers412 VERSION_CONFLICTon a stale write.X-Client-Op-Idis echoed into the change, so the sender skips its own echo; stale snapshots are dropped by version./projects/{id}carryX-Change-Seq/X-Change-Epoch; the client seeds its cursor from the first one.events/registry.json, read by API, realtime and web tests (regen:go test ./internal/events -run TestRegistryIsUpToDate -update-registry).COLLAB_CLUSTER,REPLICA_ID,ACCESS_CACHE_TTL_MS. Helm still needsrealtime.allowMultipleReplicas=truefor >1 replica, now because the polling transport needs sticky sessions.Docs:
services/realtime/README.md(protocol, guarantees, limits, replicas), architecture docs, Helm README/values,apps/e2e/README.md.Deliberately not done
If-Matchfor docs and in the web editor; removing the plain event path.Testing
internalGo tests, realtime (142), web (1618) pass.sync-gaps(versions, If-Match race, client op id, change head, outbox repairs) andsync-replicas(second realtime container: cross-replica edits, late joiner, killing a replica), plus thesync-uifirst-join window test.apps/e2ewith the sync flag on, and real GitHub/GitLab paths.interaction-views.spec.ts"Clearing the filter restores all tasks" fails identically on the committed API and web images; "Save only for me" in that file is flaky.