feat: ship loose-offline dbsync (validate, agent push, LWW audit)

Add UUID/FK channel checks, agent whitelist/push APIs, bindings, super-admin LWW audit with rollback, reconcile rate limits, and sync docs. Default customers stay opt-in; company conflict UI is removed.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
whm
2026-07-31 17:54:14 +08:00
parent 632057c857
commit 76cdcd760e
39 changed files with 3302 additions and 199 deletions

View File

@@ -8,6 +8,7 @@ import (
"os"
"os/signal"
"syscall"
"time"
"aijianzhan/platform/internal/config"
"aijianzhan/platform/internal/handler"
@@ -39,6 +40,34 @@ func main() {
defer cancel()
if ctx.DBSync != nil {
ctx.DBSync.StartAll(runCtx)
ttlDays := c.DBSync.LwwAuditTTLDays
if ttlDays <= 0 {
ttlDays = 90
}
go func() {
t := time.NewTicker(6 * time.Hour)
defer t.Stop()
purge := func() {
cutoff := time.Now().UTC().Add(-time.Duration(ttlDays) * 24 * time.Hour)
n, err := ctx.DBSync.Store().PurgeLwwOverridesBefore(cutoff)
if err != nil {
fmt.Printf("dbsync lww purge: %v\n", err)
return
}
if n > 0 {
fmt.Printf("dbsync lww purge: removed %d\n", n)
}
}
purge()
for {
select {
case <-runCtx.Done():
return
case <-t.C:
purge()
}
}
}()
}
go func() {