Push over SSE: a signal not state
Status
Section titled “Status”Accepted. The framework module is built in Go and Java, and the platform gateway is built in Go. Some SDK readers and the load tests on the target environment are still to do.
2026-11-08 (framework contract); 2026-11-09 (platform gateway).
Context
Section titled “Context”Screens and field devices need to hear that something changed (“order 7 changed”, “a job was assigned to you”) without polling. A push is not a domain event. It is whatever a screen needs to hear. Doing this well with more than one server instance raises problems: a message must not be sent for a change that rolled back, instances must agree on order, a client that reconnects must not miss messages, and a client that was away too long must be told to reload.
Decision
Section titled “Decision”- Server-sent events are the transport. They work from a browser
EventSource, resume withLast-Event-ID, and pass through ordinary HTTP infrastructure. - A push is written in the same transaction as the change. In a use case it is a plan step. It goes to a push outbox table and a notification. It exists only if the transaction commits.
- One relay at a time, gated by a lock with a fencing token, moves outbox rows into an ordered log. Log ids are assigned only to committed rows by one writer, so a client that has seen id 41 is never owed id 40.
- The guarantee: every committed push is delivered to every stream subscribed to its topic, in log order, once, as long as the stream stays open or resumes within the retention window. Retention is at most 24 hours. A stream that resumes from further back, or with an invalid id, receives a
resetevent and reloads its state. - Two log drivers behind one contract: Postgres (default) and Redis, with the same contract tests and conformance vectors.
- Signals, not state, by default. Pushes should say what changed and the client reads the state through the application’s API, which applies normal access checks. State may be carried where it is safe for everyone allowed on the topic.
- Topics carry access rules. Subscribing is a request that is granted per topic by a rule or a ticket and returns a signed stream token. Every push has a client (tenant), checked on every stream after the topic match.
- Backpressure and limits apply per stream and per application: topics per request, data size, stream lifetime, streams and rate.
- A platform gateway is a separate, opt-in service (
FC_PUSH_ENABLED) for applications that do not run their own host. It is multi-application, keeps rules, ticket keys and limits in the platform database, accepts the platform’s tokens and field tokens, and ends streams on sign-out and session revocation. It runs separately in non-development environments and starts on the Postgres log, switching to Redis past stated thresholds. Delivery is instant: the outbox processor wakes on a push row.
Consequences
Section titled “Consequences”Good:
- No phantom pushes: a rolled-back change sends nothing.
- Order and replay are consistent across instances, and a long absence is handled explicitly.
- The same wire and behaviour whether an application hosts its own stream or uses the gateway.
Bad:
- Delivery is at-least-once in practice across reconnects. The client must tolerate a signal for state it already has.
- One relay is a single writer per host. A crash delays pushes by up to the lock lease (five seconds by default).
- The log is per host, so ids mean nothing across hosts.
- Retention bounds replay to 24 hours. Longer absences reload.
- Portal users are not subscribers in the first gateway release. Applications mint tickets for them.
Alternatives considered
Section titled “Alternatives considered”| Alternative | Why not |
|---|---|
| WebSockets | Two-way is not needed. SSE is simpler to run behind ordinary proxies and resumes natively. |
| Publishing straight to a broker after the write | A crash between commit and publish loses the push, or sends one for a rollback. |
| Domain events as the push mechanism | Events are the audited record of business facts. A screen hint is not one. |
| Pushing full state by default | Bypasses per-request access checks and can show stale or over-shared data. |