Skip to content

POC: one registry return for the Postgres bus - #4605

Closed
cursor[bot] wants to merge 6 commits into
mainfrom
poc/one-postgres-registry
Closed

cursor[bot] wants to merge 6 commits into
mainfrom
poc/one-postgres-registry

Conversation

@cursor

@cursor cursor Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

This PR does not merge

A smaller shape of #4598. Fold the subtraction into fix/FIX-2427-postgres-bus, then close this unmerged.

What I subtracted

createPostgresStores built the registry twice. The connection-string branch returned its own copy, and the bus (notify: true, close() before the pools) was pasted into both. One return now serves every shape. Net −20 lines in packages/store-postgres/src/index.ts.

The connection-string shape still initializes schema on a dedicated client. schemaInitialized keeps the shared path from doing it again on the pool. { pool } and a connection string still pg_notify with no tail pool. An { executor } still does not, unless a tail pool is passed.

What still passes

pnpm exec vitest run --root packages/store-postgres test/pool-options.test.ts test/skip-schema-init.test.ts test/postgres-bus.test.ts test/postgres-bus-stream.test.ts test/listen-tail.test.ts — 31 passed.

A throwaway check, not in this diff: a connection string still notifies, and pg_advisory_lock stays off the pool. Removing schemaInitialized = true fails that check (the pool runs the lock). A { pool } with no tail still notifies, and crossesProcesses stays false.

No product behavior change. Do not merge.

Open in Web View Automation 

claude and others added 6 commits November 3, 2026 02:57
…on another

postgresStores backs the bus slot. A notice reaches the writing process's
views at once and goes out as pg_notify('fsd_bus'); one LISTEN connection per
process with an open view, from the tail pool, fans notices out. The bus says
it crosses processes only while it hears its own ping (every 2 s, stale after
3 s), so behind a pooler or after a drop views keep the timed read; it
reconnects without giving up, resyncs, and warns once when the first ping
never comes back. Request tails share the new listen helper.

Engine cleanups promised on #4594: one bus per wrapped store (a second is
refused), one deferral hop and one microtask per publish, and notice-assembly
failures debug-logged instead of swallowed.

Goal check goals/session-stream/wakes-across-processes/ on two forked
processes over a real Postgres, with goals/lib/postgres.mts and peers.mts
shared with the closure goal (FIX-2368).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UNkLEJU1iqxFYoPadTRfn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UNkLEJU1iqxFYoPadTRfn
Gloss crossesProcesses and link the engine's Change bus section; state the
notice's real guarantee (sent only once the write lands); give the silent-drop
bound as computed; make the serverless advice agree with the liveTailPool fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UNkLEJU1iqxFYoPadTRfn
…t opens

Codex on #4598. A notice sent after a view's first read and before the
process's first LISTEN took effect was heard by nobody, and the first ping then
said "crosses" and stopped the view's timed read: the view stayed stale. The
bus now sends every subscriber a resync on each connection, the first
included, before a ping can say it crosses.

openListen could hand back a connection that failed between LISTEN answering
and the helper resuming, with no loss callback; a request tail then waited out
its liveness timeout instead of reconnecting. The helper now refuses it, as a
failed LISTEN is refused, so every caller reconnects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UNkLEJU1iqxFYoPadTRfn
The connection-string branch returned its own copy of the store list, including the bus. It now joins the return the other shapes already use. Schema init stays on the dedicated client.

Co-authored-by: Jake Hoffner <jhoffner@users.noreply.github.com>
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Nov 3, 2026 11:51am UTC
flow-state-dev-kitchen-sink Ignored Ignored Nov 3, 2026 11:51am UTC
flow-state-dev-ui Ignored Ignored Nov 3, 2026 11:51am UTC
flow-state-dev-build-site Skipped Skipped Nov 3, 2026 11:51am UTC

Request Review

jhoffner pushed a commit that referenced this pull request Nov 3, 2026
…STEN failure; one registry build

Codex on #4598 (r4454225127): a notice too large for NOTIFY went out without
its resource, and the receiving in-process fan-out gives a narrowed subscriber
only an exact resource match, so remote views narrowed to that resource never
heard it. A widened payload now carries `w: true`, and the receiver wakes every
subscriber of the scope, narrowed or not, each on its own topic.

The first failure to open the listening connection now warns once, with the
error. createPostgresStores builds its registry once for every shape (Cursor's
review, PoC #4605): the connection-string path still initializes on its
dedicated client and publishes as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UNkLEJU1iqxFYoPadTRfn
@jhoffner jhoffner closed this Nov 3, 2026
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.

3 participants