design: gossip cannot express a deletion, or restore a node's own history #52

Open
opened 2026-11-08 23:49:11 +00:00 by david · 0 comments
Owner

The dedupe pass on the laptop (see #43) exposed a structural gap rather than a bug in the sync code.

What happened

7,172 duplicate observations were removed locally. Gossip is append-only and per-node:

  • GET /v1/log?node=X serves only rows owned by X (WHERE node_id=X).
  • Push sends only node_id = self.
  • The receiver INSERT OR IGNOREs on (node_id, hcl).
  • The receiver drops rows claiming its own node_id (spoof guard).

Result: the laptop is at 8,936 rows, dhg.lol still holds 15,289 rows owned by the laptop. No sync will ever remove them, and none of them can come back either.

The two problems

1. A rewrite is invisible. Any deliberate deletion, compaction or rebuild diverges from every replica, permanently, and silently. Today the only way to keep replicas consistent is to run the same destructive pass on each one by hand. As knox grows more derived state, that stops being reasonable.

2. The replica cannot restore the origin. If this laptop's DB were lost, its own 15,289 rows on dhg.lol are unreachable: pull is scoped to the peer's node id, and the spoof guard rejects rows under ours. Restoring an older local backup is also only half-healed — peers re-send their own rows, never ours.

That means "the always-on node is my backup" is currently false, and nothing in the docs says so.

Options (not decided)

  • Tombstones. A row with (node_id, hcl, fingerprint) and a deleted marker; reconcile applies per-fingerprint LWW. Costs a second meaning for "observation" and unbounded growth unless compacted.
  • A compaction checkpoint. A normal observation, owned by the node, that says "as of hcl H I no longer hold the rows listed (or the fingerprint+content-hash set)". Replicas apply the same delete. Keeps one log, needs a bounded payload.
  • Scoped restore. Origin proves ownership (signature or a challenge over a nonce with its node key) and asks a peer for rows under its own node_id. Must not widen the spoof guard into "anyone can push as anyone".

Constraints

  • Keep the append-only model: no random UPDATE of historical rows.
  • Must not let a peer forge another node's rows or vector.
  • Payload bounded; a full-library restore must not be a single unbounded request.
  • Deterministic: the same rewrite on two nodes must converge to the same state.

Acceptance

  • Deleting a set of rows on one node converges on every replica after a sync.
  • A node that lost its DB can recover its own observations from a replica, with proof it is that node.
  • A peer cannot delete or forge another node's rows.

Context

Numbers and the cleanup itself are in #43. The 158 rows under f371930f (an older identity for this laptop) show the same problem from the other side: an abandoned node id whose data nothing can address.

The dedupe pass on the laptop (see #43) exposed a structural gap rather than a bug in the sync code. ## What happened 7,172 duplicate observations were removed locally. Gossip is append-only and per-node: - `GET /v1/log?node=X` serves **only rows owned by X** (`WHERE node_id=X`). - `Push` sends only `node_id = self`. - The receiver `INSERT OR IGNORE`s on `(node_id, hcl)`. - The receiver **drops rows claiming its own node_id** (spoof guard). Result: the laptop is at 8,936 rows, dhg.lol still holds 15,289 rows owned by the laptop. No sync will ever remove them, and none of them can come back either. ## The two problems **1. A rewrite is invisible.** Any deliberate deletion, compaction or rebuild diverges from every replica, permanently, and silently. Today the only way to keep replicas consistent is to run the same destructive pass on each one by hand. As knox grows more derived state, that stops being reasonable. **2. The replica cannot restore the origin.** If this laptop's DB were lost, its own 15,289 rows on dhg.lol are unreachable: pull is scoped to the *peer's* node id, and the spoof guard rejects rows under ours. Restoring an older local backup is also only half-healed — peers re-send their own rows, never ours. That means "the always-on node is my backup" is currently false, and nothing in the docs says so. ## Options (not decided) - **Tombstones.** A row with `(node_id, hcl, fingerprint)` and a `deleted` marker; reconcile applies per-fingerprint LWW. Costs a second meaning for "observation" and unbounded growth unless compacted. - **A compaction checkpoint.** A normal observation, owned by the node, that says "as of hcl H I no longer hold the rows listed (or the fingerprint+content-hash set)". Replicas apply the same delete. Keeps one log, needs a bounded payload. - **Scoped restore.** Origin proves ownership (signature or a challenge over a nonce with its node key) and asks a peer for rows under its own node_id. Must not widen the spoof guard into "anyone can push as anyone". ## Constraints - Keep the append-only model: no random UPDATE of historical rows. - Must not let a peer forge another node's rows or vector. - Payload bounded; a full-library restore must not be a single unbounded request. - Deterministic: the same rewrite on two nodes must converge to the same state. ## Acceptance - Deleting a set of rows on one node converges on every replica after a sync. - A node that lost its DB can recover its own observations from a replica, with proof it is that node. - A peer cannot delete or forge another node's rows. ## Context Numbers and the cleanup itself are in #43. The 158 rows under `f371930f` (an older identity for this laptop) show the same problem from the other side: an abandoned node id whose data nothing can address.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: david/knox#52