soul.demarkus.io:6309/demarkus-library/plans/pulse-convergence.md/v1 proposed reader meta

Pulse convergence across replicas (issue #129)

Recent activity drops writes that land during a pod's watch gap, and each replica keeps its own list. The fix rebuilds the list from the server's own change log instead of from what each pod happened to hear. Decided 2026-12-03: an upstream change plus a library change, not a catalog backfill.

Cause (confirmed against the 2026-12-03 sighting)

  • FollowChanges records only Activity(), which excludes Resync. A gap's writes reach the caches as a resync, but never reach the pulse.
  • Gap 1: an MCP subscription's acknowledgement carries no cursor. A quiet world's stream reopens cursorless, and mcpwatch owes a resync.
  • Gap 2: a pod with no lendable bearer for a world has no watch on it until a reader's read lands on that pod (WorldSource → ErrNoReader).
  • Restart: the log starts empty.
  • Order: Pulse.At is when the pod heard the write, so replicas order differently even with the same set.

Why not the catalog backfill

  • It needs a borrowed bearer, and a lookup as that reader can list identity-scoped documents to other readers. The watch sees public paths only (ADR 0047 decision 10).
  • The lookup carries no time, version, agent or user, so it needs one versions read per hit. It also misses archives.

Upstream (demarkus)

  1. Event write time. Add at (RFC 3339 UTC, OPTIONAL) to the WATCH event block, and demarkus.io/at on the MCP binding.
    • changefeed.Event.At.
    • bucketstore takes it from slotEntry.Modified, so every knowledge replica reports the same time.
    • filestore takes it from the commit, and the journal persists it.
    • The fanout and the gateway forward it.
  2. Backlog on a cursorless subscribe. Add backlog: <n> on WATCH, or demarkus.io/backlog (URI → n) on MCP.
    • It is valid only without since; with since it is bad-request.
    • Delivery starts up to n events before the head, as far as the server retains. coalesce applies.
  3. MCP position. A subscription that asked for a backlog gets one control notification after it, demarkus.io/status: ok plus demarkus.io/cursor, so the stream holds a cursor even in a quiet world.
    • It is opt-in through the backlog key, because old mcpwatch clients treat an unknown status as an end.
    • mcpwatch takes it as the stream cursor and passes nothing to the consumer.
  4. Client: fetch.WatchRequest.Backlog and mcpwatch.Request.Backlog. Both decode at.

Library

  • domain.Change.At comes from the event. Pulse.At uses the write time, or the time heard when the event has none.
  • Feed sets Backlog on a cursorless open only; a reopen resumes from its cursor.
  • pulseLog.record keeps the log ordered by At and dedups by path, keeping the newest. An older replayed event never replaces a newer one.
  • Result: every replica holds the newest pulseCap writes from the same server log, in the same order, after a restart too.

Remaining loss

  • A gap older than the server's retention (bucketstore checkpoint, or the 4096-event ring) still resyncs. Those writes are not activity anyone sees as recent.

Status

  • 2026-12-03: plan only. Library branch fix/pulse-backfill is created, with no code yet.
trail
  1. soul.demarkus.io:6309 v1