/** * Session leaf-advance bus — the S2 fast path of the session-level SSE subscription * ([ref]/[ref]③: an append that lands on THIS replica fans out to watchers synchronously, * zero latency on single-replica deployments; cross-replica watchers still ride the probe lane). * * Deliberately a REPLICA-LOCAL singleton (module state), not a constructor-threaded dependency: * the leaf write sits at the bottom of the per-session storage stack (TiDB/Pg `persist()` — a * static-factory + N-arg constructor chain away from main.ts), while the one consumer * (SessionWatchRegistry.notifyLocal) is replica-local by design. A bus keeps the wiring one line * per write site and one line in main; anything smarter re-plumbs four layers for the same effect. * * Contract: * - `emitLeafAdvance` MUST be fire-and-forget from the writer's perspective: it never throws * (listener errors are swallowed) and does no async work — a broken watcher must not fail or * slow a session write. * - Emit AFTER the storage commit succeeds (a rolled-back CAS must not fan out a leaf that never * became durable). * - Owner IS carried and MUST be the COMMIT-TIME row owner (codex two rounds: without owner the * generation fence is skipped; a wake-time snapshot is worse — stale-A over a reclaimed row false- * matches an old A entry and leaks the new tenant's leaf into the old stream). Zero-cost source: * the persist transaction's own leaf_seq SELECT carries the owner column — the emitted owner is the * row's tenant at the moment the write committed. * - `leafSeq`(the row's committed leaf_seq)rides every emit: DB commits serialize, but the * post-commit continuations don't — without an ordering token a delayed leaf-N delivery after * leaf-N+1 would walk the registry BACKWARD (and a stale notification could false-drop a newer * generation on owner mismatch). The registry keeps the highest accepted seq and ignores lower. * - The local (file/in-mem) lane does not emit: those sessions persist inside core's storage * backend with no server-side write hook; the probe lane covers them at its normal cadence. */ type LeafListener = (sessionId: string, leafId: string | null, owner: string | null | undefined, leafSeq: number) => void; /** main.ts wires this once at boot (→ SessionWatchRegistry.notifyLocal). Last write wins; tests reset with undefined. */ export declare function setLeafAdvanceListener(fn: LeafListener | undefined): void; /** Called by the SQL session-storage write sites post-commit. Never throws, never awaits. */ export declare function emitLeafAdvance(sessionId: string, leafId: string | null, owner: string | null | undefined, leafSeq: number): void; export {}; //# sourceMappingURL=session-leaf-bus.d.ts.map