feat: M2 composite locator + idle reconcile

Refs #1

- observations: hcl backfilled from local rowid; (node_id, hcl) UNIQUE
  locator index becomes the gossip merge key
- threads: cluster_key column + partial UNIQUE index; CreateThreadCluster
  is idempotent, threader folds into exact cluster_key before heuristic
- AutoLinkThreadObservations dedup re-expressed on hcl DESC
- new `knox reconcile [--dry-run]` rebuilds entries from the observation
  log and re-links threads idempotently (entry count, thread cluster_key
  verified bit-identical from log-only DB)
This commit is contained in:
2026-08-29 04:47:15 -07:00
parent 2c0f8fa257
commit aa0dec68c1
6 changed files with 190 additions and 22 deletions
+8 -5
View File
@@ -213,14 +213,17 @@ truth.
## 8. Milestones
**M1 — Determinism fixes (prereq).** F1 (canonical fingerprints), F2 (HLC in all
"when" columns), F3 (TF-IDF tie-break), F4 (locator IDs + `ORDER BY hcl`).
**M1 — Determinism fixes (prereq).** DONE. F1 (canonical fingerprints), F2 (HLC
in all "when" columns), F3 (TF-IDF tie-break), F4 (locator IDs + `ORDER BY hcl`).
Verify: two fresh DBs ingesting the same real content produce identical
observation hashes and identical threads (minus node_id).
**M2 — Composite PK + reconcile.** Schema migration; `knox reconcile`; `entries`
fully derived; dedup re-expressed on HCL. Verify: reconcile is idempotent; a DB
with only the log reconstructs `entries`/threads bit-identical to the original.
**M2 — Composite PK + reconcile.** DONE. HCL backfilled from local rowid;
`(node_id, hcl)` locator UNIQUE index; threads carry `cluster_key` (partial
UNIQUE index) making auto-creation idempotent; `knox reconcile` rebuilds
`entries` from the log and re-links threads. Verify: reconcile is idempotent (0
create/0 link on re-run); a log-only DB reconstructs `entries` and thread
`cluster_key`s bit-identical to the original.
**M3 — Peer protocol.** `peers` settings table, `/v1/ping`, `/v1/log` pull,
`/v1/obs/batch` push, handshake + periodic anti-entropy, echo suppression.