Files
ai_site/platform/internal/dbsync/lww_audit.go
whm 76cdcd760e 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>
2026-07-31 17:54:14 +08:00

42 lines
937 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
}