feat: M3 peer gossip protocol
Refs #1 - peers table (peer_id, addr, cursor, last_handshake) - watch serves HTTP API: GET /v1/ping (knowledge vector), GET /v1/log?node=&after= (cursor-paged pull), POST /v1/obs/batch - anti-entropy sweep (Run): ping, pull what we lack, push own obs; echo suppressed by node_id ownership; reconcile-on-pull - config via KNOX_PEERS / KNOX_PEER_ADDR; knox gossip status - db: GossipObservation wire type, PushObservations, ObservationsAfter, KnowledgeVector, peer upsert/list - integration tests: bidirectional convergence + idempotency
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package watch
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/david/knox/internal/db"
|
||||
)
|
||||
|
||||
// Reconcile rebuilds all derived state from the observation log: entries are
|
||||
// reconstituted via deterministic SQL aggregation, then the auto-threader
|
||||
// re-links/re-creates threads idempotently by cluster_key. Returns the threads
|
||||
// created and observations linked.
|
||||
func Reconcile(kdb *db.KnoxDB) (int, int, error) {
|
||||
if _, _, err := kdb.RebuildEntriesFromObservations(); err != nil {
|
||||
return 0, 0, fmt.Errorf("rebuild entries: %w", err)
|
||||
}
|
||||
threader := NewAutoThreader(kdb)
|
||||
created, linked, err := threader.AutoThread()
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("auto-thread: %w", err)
|
||||
}
|
||||
return created, linked, nil
|
||||
}
|
||||
Reference in New Issue
Block a user