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:
41
platform/internal/dbsync/lww_audit.go
Normal file
41
platform/internal/dbsync/lww_audit.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package dbsync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
EntryDrain = "drain"
|
||||
EntryAgentPush = "agent_push"
|
||||
EntryRollback = "rollback"
|
||||
OutcomeApplied = "applied_source"
|
||||
OutcomeKept = "kept_target"
|
||||
OutcomeRolled = "rolled_back"
|
||||
)
|
||||
|
||||
// RecordLwwOverride 在 LWW 覆盖或保留目标时写入超管审计(失败忽略,不挡同步)。
|
||||
func RecordLwwOverride(store *FileStore, o LwwOverride) {
|
||||
if store == nil {
|
||||
return
|
||||
}
|
||||
_ = store.AddLwwOverride(o)
|
||||
}
|
||||
|
||||
// SnapshotTargetRow 取目标端当前行 JSON(无行则空串)。
|
||||
func SnapshotTargetRow(ctx context.Context, db *sql.DB, driver Driver, table, pkCol, rowPK string) string {
|
||||
if db == nil || rowPK == "" {
|
||||
return ""
|
||||
}
|
||||
js, _, err := FetchRowJSON(ctx, db, driver, table, pkCol, rowPK)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return js
|
||||
}
|
||||
|
||||
// DefaultLwwAuditTTL 默认 90 天。
|
||||
func DefaultLwwAuditTTL() time.Duration {
|
||||
return 90 * 24 * time.Hour
|
||||
}
|
||||
Reference in New Issue
Block a user