Skip to content

feat: add scalable MessagesSubscribe mesh invalidation stream #255

Description

@LiranCohen

Problem

Role-only invite/preauth nodes cannot open one broad role-authorized RecordsSubscribe stream. Production requires exact protocolPath and direct-parent context filters, which would grow to roughly 4 + members + 2*nodes subscriptions per node and O(N^2) server state.

Target design

Use one network-context-scoped MessagesSubscribe stream per node as the authoritative invalidation feed:

  • prefix filters for the mesh member, node, ACL, and relay subtrees
  • owner-issued Messages/Read observer grant scoped to the network context
  • structured ProgressToken resume, EOSE, gap repair, and terminal grant revocation using the shared subscription lifecycle from fix: align DWN subscription protocol #254
  • events only invalidate/coalesce; the daemon continues serving its immutable last-good snapshot
  • full reconciliation only on startup/fresh establishment, progress gap, ambiguous event, health recovery, and slow anti-entropy

Required work

  1. Update the Enbox SDK/server authorization projection so contextIdPrefix/protocolPathPrefix filters are contained by scoped Messages grants, with positive and negative tests.
  2. Add a Go MessagesSubscribe builder/parser reusing the existing WebSocket reconnect state machine.
  3. Issue, persist, renew, and revoke observer grants during node approval/removal; backfill existing nodes.
  4. Expose stream health and switch healthy nodes from 30s polling to 5-10 minute anti-entropy.
  5. Keep explicit polling fallback until observer grant coverage is confirmed.

This avoids non-atomic revision dual-writes and quadratic path-scoped subscriptions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions