v2.0.0: claims model - signed MMUR2 votes in a truth DB, merged view in a rebuildable cache DB; POST /api/claims, claims and merge routes, unsigned writes answer 410
Build and Push Docker Image / build (push) Successful in 5m1s

This commit is contained in:
Worph
2026-10-25 17:36:00 +00:00
parent b0adefb97b
commit 84af298792
78 changed files with 7203 additions and 5617 deletions
+20 -9
View File
@@ -6,6 +6,7 @@ import (
"log"
"os"
"os/signal"
"path/filepath"
"syscall"
"time"
@@ -17,7 +18,7 @@ import (
)
// Version is set at build time
var Version = "1.0.0"
var Version = "2.0.0"
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
@@ -30,26 +31,36 @@ func main() {
// Create leader info provider (Go binary only runs as leader - followers loop in bash)
leaderProvider := leader.NewLeaderInfoProvider(cfg)
// Open the metadata store: an embedded SQLite file (internal/kv). There
// is no separate database process to wait for.
// Open the two embedded SQLite files: truth (signed claims, backed up)
// and the cache (everything derived, rebuildable). No database process.
if err := os.MkdirAll(filepath.Dir(cfg.CachePath()), 0o755); err != nil {
log.Fatalf("[meta-core] Failed to create the cache folder: %v", err)
}
storageClient := storage.NewClient()
if err := storageClient.Connect(cfg.DBPath()); err != nil {
if err := storageClient.Connect(cfg.DBPath(), cfg.CachePath()); err != nil {
log.Fatalf("[meta-core] Failed to open the metadata store: %v", err)
}
// Schema-version sentinel: alpha clean-wipe gate. Refuses to boot when
// the existing store predates the UUID-rooted schema, so legacy data
// can't silently leak into the new code paths. See
// docs/uuid-rooted-metadata.md.
// Schema-version gate: refuses a v1.x store (which the default truth path
// still points at) and any unknown layout. No migration code here — see
// tools/claims-migrate.
if err := storageClient.EnsureSchemaVersion(storage.SchemaVersion); err != nil {
log.Fatalf("[meta-core] %v", err)
}
log.Printf("[meta-core] Store schema version OK (v%d)", storage.SchemaVersion)
// Bring the cache level with truth (replay after a crash, full rebuild
// when the cache folder is empty), then start the apply loop.
started := time.Now()
if err := storageClient.Start(); err != nil {
log.Fatalf("[meta-core] %v", err)
}
log.Printf("[meta-core] Cache ready in %s", time.Since(started).Round(time.Millisecond))
// Derived counters (record count, per-field schema) are kept exact by the
// write path. A store that predates them gets a one-time build here,
// before anything else writes.
started := time.Now()
started = time.Now()
if built, err := storageClient.EnsureCounters(); err != nil {
log.Fatalf("[meta-core] Failed to build the store's derived counters: %v", err)
} else if built {