Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Keep undated TrueNAS snapshots from inventing backup freshness
pulse-triage[bot]d3736fa60e32
diff --git a/docs/TRUENAS.md b/docs/TRUENAS.mdindex e03a63a2cf..395df03448 100644--- a/docs/TRUENAS.md+++ b/docs/TRUENAS.md@@ -98,11 +98,12 @@ record in TrueNAS:**Last snapshot** describe collected evidence, not a restore test.**Running** remains incomplete even if a timestamp is present. A successfulsnapshot observation does not establish successful replication.- **Current timestamp limitation:** when TrueNAS supplies no snapshot creation- time, Pulse can show the collection time as **Completed**. Do not use that- displayed time alone to judge backup age or retention; confirm the native- snapshot's creation time. Replication with no known last-run time is- **Unknown**, not a newly completed copy.+ **Missing snapshot creation time is Unknown:** the row has no **Completed**+ timestamp. A new collection cannot make an undated snapshot newer. Earlier+ releases could show collection time as **Completed**; those undated records+ are corrected on upgrade without deleting snapshot history. To judge backup+ age or retention, confirm the native snapshot's creation time. Replication+ with no known last-run time is **Unknown**, not a newly completed copy.3. **Check the destination without starting work.** Use the provider's existingreceived-snapshot and task records. Confirm the same source snapshot, targetand successful transfer result. Missing **Verified**, **Size** or timestampdiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 40db273b47..06dfd8d8a2 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -21,6 +21,24 @@## Purpose+### TrueNAS snapshot collection is not creation evidence++Undated or zero-date ZFS snapshots retain no start/completion time and have+Unknown outcome. Their IDs remain stable across polls regardless of collection+time; native dated snapshot IDs/times and replication semantics are unchanged.+On store open, former successful snapshot rows with a completion but no start+(the old collection-time fallback) become undated Unknown observations. Every+row, ID and reference remains; valid detail objects retain the old synthetic+value as `legacyCollectedAtMs`, not creation evidence. No schema or retention+change, deletion, native snapshot, replication or restore is performed.++Undated snapshots cannot create successful-point, attempt-date or dated-series+claims from collection/insertion time. The mapper, reopened-store, rollup and+series controls in `mapper/truenas/mapper_test.go` and `store/store_test.go`+cover missing/zero/known dates, repeated collection, legacy correction and+provider/kind/mode isolation. The consuming TrueNAS Protection table and guide+retain missing dates as unavailable evidence rather than a fresh backup.+### Future backup dates cannot establish current protectionProtection freshness and verification must fall at or before their evaluationdiff --git a/frontend-modern/public/docs/TRUENAS.md b/frontend-modern/public/docs/TRUENAS.mdindex e03a63a2cf..395df03448 100644--- a/frontend-modern/public/docs/TRUENAS.md+++ b/frontend-modern/public/docs/TRUENAS.md@@ -98,11 +98,12 @@ record in TrueNAS:**Last snapshot** describe collected evidence, not a restore test.**Running** remains incomplete even if a timestamp is present. A successfulsnapshot observation does not establish successful replication.- **Current timestamp limitation:** when TrueNAS supplies no snapshot creation- time, Pulse can show the collection time as **Completed**. Do not use that- displayed time alone to judge backup age or retention; confirm the native- snapshot's creation time. Replication with no known last-run time is- **Unknown**, not a newly completed copy.+ **Missing snapshot creation time is Unknown:** the row has no **Completed**+ timestamp. A new collection cannot make an undated snapshot newer. Earlier+ releases could show collection time as **Completed**; those undated records+ are corrected on upgrade without deleting snapshot history. To judge backup+ age or retention, confirm the native snapshot's creation time. Replication+ with no known last-run time is **Unknown**, not a newly completed copy.3. **Check the destination without starting work.** Use the provider's existingreceived-snapshot and task records. Confirm the same source snapshot, targetand successful transfer result. Missing **Verified**, **Size** or timestampdiff --git a/frontend-modern/src/features/docs/__tests__/truenasProtectionEvidenceDocs.test.ts b/frontend-modern/src/features/docs/__tests__/truenasProtectionEvidenceDocs.test.tsindex 801723dc93..8473ed51f5 100644--- a/frontend-modern/src/features/docs/__tests__/truenasProtectionEvidenceDocs.test.ts+++ b/frontend-modern/src/features/docs/__tests__/truenasProtectionEvidenceDocs.test.ts@@ -56,7 +56,10 @@ describe('TrueNAS protection evidence help', () => {`${snapshots} snapshots and ${replications} replication tasks per collection`,);expect(text).toContain('retained events can outlive their source artifact');- expect(text).toContain('Pulse can show the collection time as Completed');+ expect(text).toContain('Missing snapshot creation time is Unknown');+ expect(text).toContain('the row has no Completed timestamp');+ expect(text).toContain('A new collection cannot make an undated snapshot newer');+ expect(text).toContain('corrected on upgrade without deleting snapshot history');expect(text).toContain("confirm the native snapshot's creation time");expect(text).toContain('Running remains incomplete even if a timestamp is present');expect(text).toContain('Replication with no known last-run time is Unknown');diff --git a/frontend-modern/src/features/truenas/__tests__/TrueNASProtectionTable.test.tsx b/frontend-modern/src/features/truenas/__tests__/TrueNASProtectionTable.test.tsxindex 7951c7c798..7252749280 100644--- a/frontend-modern/src/features/truenas/__tests__/TrueNASProtectionTable.test.tsx+++ b/frontend-modern/src/features/truenas/__tests__/TrueNASProtectionTable.test.tsx@@ -140,4 +140,50 @@ describe('TrueNASProtectionTable', () => {'false',);});++ it('keeps undated snapshots unknown and dateless without hiding their artifact details', async () => {+ renderInRouter(() => (+ <TrueNASProtectionTable+ points={[+ makeRecoveryPoint({+ id: 'undated',+ kind: 'snapshot',+ mode: 'snapshot',+ outcome: 'unknown',+ startedAt: undefined,+ completedAt: undefined,+ details: { dataset: 'tank/undated', fullName: 'tank/undated@daily', snapshot: 'daily' },+ }),+ makeRecoveryPoint({ id: 'known', kind: 'snapshot', mode: 'snapshot' }),+ makeRecoveryPoint({ id: 'running', kind: 'backup', mode: 'remote', outcome: 'running' }),+ ]}+ emptyIcon={<span />}+ emptyTitle="No protection"+ emptyDescription="No protection"+ />+ ));+ await fireEvent.click(screen.getByRole('button', { name: 'Unknown, 1' }));+ const rows = document.querySelectorAll('[data-truenas-protection-row]');+ expect(rows).toHaveLength(1);+ const row = rows[0];+ expect(row).toHaveAttribute('data-truenas-protection-outcome', 'unknown');+ expect(within(row as HTMLElement).getByText('Unknown')).toBeInTheDocument();+ expect(row.querySelectorAll('td')[3]).toHaveTextContent('-');+ await fireEvent.click(row);+ const detail = within(screen.getByTestId('truenas-protection-detail'));+ expect(detail.getByText('tank/undated@daily')).toBeInTheDocument();+ expect(detail.queryByText('Started', { exact: true })).not.toBeInTheDocument();+ expect(detail.queryByText('Completed', { exact: true })).not.toBeInTheDocument();+ await fireEvent.click(detail.getByRole('button', { name: /^Collapse .* details$/ }));+ await fireEvent.click(screen.getByRole('button', { name: 'Healthy, 1' }));+ expect(document.querySelector('[data-truenas-protection-row]')).toHaveAttribute(+ 'data-truenas-protection-row',+ 'known',+ );+ await fireEvent.click(screen.getByRole('button', { name: 'Running, 1' }));+ expect(document.querySelector('[data-truenas-protection-row]')).toHaveAttribute(+ 'data-truenas-protection-row',+ 'running',+ );+ });});diff --git a/internal/recovery/mapper/truenas/mapper.go b/internal/recovery/mapper/truenas/mapper.goindex 643cc8b36d..d365c94664 100644--- a/internal/recovery/mapper/truenas/mapper.go+++ b/internal/recovery/mapper/truenas/mapper.go@@ -3,7 +3,6 @@ package truenasmapperimport ("sort""strings"- "time""github.com/rcourtman/pulse-go-rewrite/internal/recovery""github.com/rcourtman/pulse-go-rewrite/internal/recovery/idgen"@@ -42,11 +41,6 @@ func FromTrueNASSnapshot(connectionID string, snapshot *truenas.FixtureSnapshot)conn := strings.TrimSpace(connectionID)host := strings.TrimSpace(snapshot.System.Hostname)- collectedAt := snapshot.CollectedAt- if collectedAt.IsZero() {- collectedAt = time.Now().UTC()- }-points := make([]recovery.RecoveryPoint, 0, len(snapshot.ZFSSnapshots)+len(snapshot.ReplicationTasks))zfsSnaps := append([]truenas.ZFSSnapshot(nil), snapshot.ZFSSnapshots...)@@ -86,10 +80,15 @@ func FromTrueNASSnapshot(connectionID string, snapshot *truenas.FixtureSnapshot)}completedAt := s.CreatedAt+ if completedAt != nil && completedAt.IsZero() {+ completedAt = nil+ }startedAt := completedAt+ outcome := recovery.OutcomeSuccessif completedAt == nil {- t := collectedAt- completedAt = &t+ // A collection observes an artifact, not when it was created. Keep+ // undated snapshots unknown and their IDs stable across collections.+ outcome = recovery.OutcomeUnknown}id := idgen.StableID(string(recovery.ProviderTrueNAS), conn, "zfs-snapshot", full, idgen.TimeKey(completedAt, startedAt))@@ -99,7 +98,7 @@ func FromTrueNASSnapshot(connectionID string, snapshot *truenas.FixtureSnapshot)Provider: recovery.ProviderTrueNAS,Kind: recovery.KindSnapshot,Mode: recovery.ModeSnapshot,- Outcome: recovery.OutcomeSuccess,+ Outcome: outcome,StartedAt: startedAt,CompletedAt: completedAt,SizeBytes: s.UsedBytes,diff --git a/internal/recovery/mapper/truenas/mapper_test.go b/internal/recovery/mapper/truenas/mapper_test.goindex 4f89cf852b..6250dadc9f 100644--- a/internal/recovery/mapper/truenas/mapper_test.go+++ b/internal/recovery/mapper/truenas/mapper_test.go@@ -5,6 +5,7 @@ import ("time""github.com/rcourtman/pulse-go-rewrite/internal/recovery"+ "github.com/rcourtman/pulse-go-rewrite/internal/recovery/idgen""github.com/rcourtman/pulse-go-rewrite/internal/truenas")@@ -294,3 +295,63 @@ func TestFromTrueNASSnapshot_FinishedReplication(t *testing.T) {})}}++func TestFromTrueNASSnapshot_MissingCreationTime(t *testing.T) {+ collected := time.Date(2026, 10, 25, 20, 0, 0, 0, time.UTC)+ zero := time.Time{}+ for _, tc := range []struct {+ name string+ created *time.Time+ }{+ {"absent", nil},+ {"zero", &zero},+ } {+ t.Run(tc.name, func(t *testing.T) {+ snapshot := &truenas.FixtureSnapshot{ZFSSnapshots: []truenas.ZFSSnapshot{{+ ID: "tank/apps@daily", FullName: "tank/apps@daily", CreatedAt: tc.created,+ }}}+ var id string+ for _, at := range []time.Time{collected, collected.Add(time.Hour), {}} {+ snapshot.CollectedAt = at+ points := FromTrueNASSnapshot("nas-a", snapshot)+ if len(points) != 1 {+ t.Fatalf("got %d points, want 1", len(points))+ }+ p := points[0]+ if p.StartedAt != nil || p.CompletedAt != nil || p.Outcome != recovery.OutcomeUnknown {+ t.Errorf("undated snapshot gained creation/success evidence: %+v", p)+ }+ if p.ID == "" {+ t.Fatal("missing artifact identity")+ }+ if id != "" && id != p.ID {+ t.Errorf("collection changed ID: %s -> %s", id, p.ID)+ }+ id = p.ID+ if p.SubjectRef.ID != "tank/apps" || p.Details["snapshot"] != "daily" {+ t.Errorf("lost snapshot identity: %+v", p)+ }+ other := FromTrueNASSnapshot("nas-b", snapshot)+ if other[0].ID == id {+ t.Error("connections share an artifact ID")+ }+ }+ })+ }+}++func TestFromTrueNASSnapshot_PreservesNativeCreationTimeAndIdentity(t *testing.T) {+ created := time.Date(2026, 10, 1, 12, 30, 0, 123000000, time.FixedZone("native", 3600))+ snapshot := &truenas.FixtureSnapshot{ZFSSnapshots: []truenas.ZFSSnapshot{{+ FullName: "tank/apps@daily", CreatedAt: &created,+ }}}+ wantID := idgen.StableID("truenas", "nas-a", "zfs-snapshot", "tank/apps@daily", created.UTC().Format(time.RFC3339Nano))+ for _, at := range []time.Time{created.Add(time.Hour), created.Add(24 * time.Hour), {}} {+ snapshot.CollectedAt = at+ p := FromTrueNASSnapshot("nas-a", snapshot)[0]+ if p.ID != wantID || p.Outcome != recovery.OutcomeSuccess || p.StartedAt == nil || p.CompletedAt == nil ||+ !p.StartedAt.Equal(created) || !p.CompletedAt.Equal(created) {+ t.Fatalf("native creation/identity changed: %+v, want %s at %s", p, wantID, created)+ }+ }+}diff --git a/internal/recovery/store/store.go b/internal/recovery/store/store.goindex bce11f4bd6..199ce7a09b 100644--- a/internal/recovery/store/store.go+++ b/internal/recovery/store/store.go@@ -733,7 +733,7 @@ func (s *Store) initSchema() error {if _, err := s.db.Exec(postMigrationIndexes); err != nil {return err}- return nil+ return s.correctTrueNASSnapshotCollectionTimes()}func (s *Store) ensureColumn(table string, column string, typeSQL string) error {@@ -1940,9 +1940,12 @@ func (s *Store) ListRollups(ctx context.Context, opts recovery.ListPointsOptionsargs = append(args, strings.TrimSpace(opts.SubjectResourceID))}- // Rollup time window is based on the best-known timestamp for a point.- // Prefer completed, then started, then created.- tsExpr := "COALESCE(completed_at_ms, started_at_ms, created_at_ms)"+ // An undated TrueNAS snapshot has no native attempt time. Its insertion+ // time is collection evidence, not a snapshot creation or backup attempt.+ // Preserve the historical fallback for other recovery producers.+ tsExpr := `CASE WHEN provider = 'truenas' AND kind = 'snapshot' AND mode = 'snapshot'+ THEN COALESCE(completed_at_ms, started_at_ms)+ ELSE COALESCE(completed_at_ms, started_at_ms, created_at_ms) END`if opts.From != nil && !opts.From.IsZero() {where = append(where, tsExpr+" >= ?")args = append(args, opts.From.UTC().UnixMilli())diff --git a/internal/recovery/store/store_test.go b/internal/recovery/store/store_test.goindex 026804aa71..da3ad6e941 100644--- a/internal/recovery/store/store_test.go+++ b/internal/recovery/store/store_test.go@@ -1173,3 +1173,221 @@ func TestStore_TrueNASFinishedReplicationRollup(t *testing.T) {})}}++func TestStore_TrueNASSnapshotMissingTimeDoesNotAdvanceRecovery(t *testing.T) {+ ctx := context.Background()+ at := time.Now().UTC().Truncate(time.Second)+ created := at.Add(-24 * time.Hour)+ zero := time.Time{}+ snapshot := &truenas.FixtureSnapshot{+ System: truenas.SystemInfo{Hostname: "fixture-nas"},+ ZFSSnapshots: []truenas.ZFSSnapshot{+ {FullName: "tank/undated@daily"},+ {FullName: "tank/zero@daily", CreatedAt: &zero},+ {FullName: "tank/known@daily", CreatedAt: &created},+ },+ ReplicationTasks: []truenas.ReplicationTask{+ {ID: "running", Name: "running", SourceDatasets: []string{"tank/running"}, LastRun: &at, LastState: "RUNNING"},+ {ID: "no-run", Name: "no-run", SourceDatasets: []string{"tank/no-run"}, LastState: "SUCCESS"},+ },+ }+ path := filepath.Join(t.TempDir(), "recovery.db")+ db, err := Open(path)+ if err != nil {+ t.Fatal(err)+ }+ t.Cleanup(func() { _ = db.Close() })+ var undated recovery.RecoveryPoint+ for _, collected := range []time.Time{at, at.Add(time.Hour), {}} {+ snapshot.CollectedAt = collected+ points := truenasmapper.FromTrueNASSnapshot("nas-a", snapshot)+ if err := db.UpsertPoints(ctx, points); err != nil {+ t.Fatal(err)+ }+ for _, p := range points {+ if p.Details["fullName"] == "tank/undated@daily" {+ undated = p+ }+ }+ }+ if err := db.Close(); err != nil {+ t.Fatal(err)+ }+ db, err = Open(path)+ if err != nil {+ t.Fatal(err)+ }+ points, total, err := db.ListPoints(ctx, recovery.ListPointsOptions{Limit: 50})+ if err != nil {+ t.Fatal(err)+ }+ if total != 5 || len(points) != 5 {+ t.Fatalf("repeated collection added events: total=%d len=%d, want 5", total, len(points))+ }+ for _, p := range points {+ switch p.SubjectRef.ID {+ case "tank/undated", "tank/zero", "tank/no-run":+ if p.Outcome != recovery.OutcomeUnknown || p.StartedAt != nil || p.CompletedAt != nil {+ t.Errorf("undated artifact gained completion: %+v", p)+ }+ case "tank/known":+ if p.Outcome != recovery.OutcomeSuccess || p.CompletedAt == nil || !p.CompletedAt.Equal(created) {+ t.Errorf("native snapshot lost its date/outcome: %+v", p)+ }+ case "tank/running":+ if p.Outcome != recovery.OutcomeRunning || p.CompletedAt == nil || !p.CompletedAt.Equal(at) {+ t.Errorf("running replication changed: %+v", p)+ }+ default:+ t.Errorf("unexpected artifact: %+v", p)+ }+ }+ assertUndatedTrueNASRollupAndSeries(t, db, undated)+ from, to := created.Add(-time.Hour), at.Add(time.Hour)+ series, err := db.ListPointsSeries(ctx, recovery.ListPointsOptions{From: &from, To: &to}, 0)+ if err != nil {+ t.Fatal(err)+ }+ var events int+ for _, day := range series {+ events += day.Total+ }+ if events != 2 {+ t.Errorf("dated activity=%d, want only native snapshot and dated running task", events)+ }+}++func TestStore_OpenCorrectsTrueNASSnapshotCollectionTimes(t *testing.T) {+ ctx := context.Background()+ at := time.Now().UTC().Truncate(time.Second)+ created := at.Add(-24 * time.Hour)+ path := filepath.Join(t.TempDir(), "recovery.db")+ db, err := Open(path)+ if err != nil {+ t.Fatal(err)+ }+ t.Cleanup(func() { _ = db.Close() })+ // Recreate the old mapper's asymmetric dates, retaining all artifact evidence.+ legacy := truenasmapper.FromTrueNASSnapshot("nas-a", &truenas.FixtureSnapshot{+ ZFSSnapshots: []truenas.ZFSSnapshot{{FullName: "tank/undated@daily", UsedBytes: ptrInt64Store(1234)}},+ })[0]+ legacy.ID, legacy.StartedAt, legacy.CompletedAt, legacy.Outcome = "legacy-poll-1", nil, &at, recovery.OutcomeSuccess+ legacy.Details["retained"] = "artifact-evidence"+ second := legacy+ second.ID = "legacy-poll-2"+ later := at.Add(time.Minute)+ second.CompletedAt = &later+ known := truenasmapper.FromTrueNASSnapshot("nas-a", &truenas.FixtureSnapshot{+ ZFSSnapshots: []truenas.ZFSSnapshot{{FullName: "tank/known@daily", CreatedAt: &created}},+ })[0]+ controls := []recovery.RecoveryPoint{known}+ for _, tc := range []struct {+ id string+ provider recovery.Provider+ kind recovery.Kind+ mode recovery.Mode+ outcome recovery.Outcome+ }{+ {"replication", recovery.ProviderTrueNAS, recovery.KindBackup, recovery.ModeRemote, recovery.OutcomeSuccess},+ {"other-provider", recovery.ProviderKubernetes, recovery.KindSnapshot, recovery.ModeSnapshot, recovery.OutcomeSuccess},+ {"other-mode", recovery.ProviderTrueNAS, recovery.KindSnapshot, recovery.ModeRemote, recovery.OutcomeSuccess},+ {"other-kind", recovery.ProviderTrueNAS, recovery.KindBackup, recovery.ModeSnapshot, recovery.OutcomeSuccess},+ {"failed-snapshot", recovery.ProviderTrueNAS, recovery.KindSnapshot, recovery.ModeSnapshot, recovery.OutcomeFailed},+ } {+ p := legacy+ p.ID, p.Provider, p.Kind, p.Mode, p.Outcome = tc.id, tc.provider, tc.kind, tc.mode, tc.outcome+ p.SubjectRef = &recovery.ExternalRef{Type: "fixture-control", ID: tc.id, Name: tc.id}+ controls = append(controls, p)+ }+ seed := append([]recovery.RecoveryPoint{legacy, second}, controls...)+ if err := db.UpsertPoints(ctx, seed); err != nil {+ t.Fatal(err)+ }+ // A corrupt details field must not turn this bounded correction into an open failure.+ broken := legacy+ broken.ID = "legacy-broken-details"+ if err := db.UpsertPoints(ctx, []recovery.RecoveryPoint{broken}); err != nil {+ t.Fatal(err)+ }+ if _, err := db.db.Exec(`UPDATE recovery_points SET details_json = '{broken' WHERE id = ?`, broken.ID); err != nil {+ t.Fatal(err)+ }+ if err := db.Close(); err != nil {+ t.Fatal(err)+ }+ for reopen := 0; reopen < 2; reopen++ {+ db, err = Open(path)+ if err != nil {+ t.Fatal(err)+ }+ points, total, err := db.ListPoints(ctx, recovery.ListPointsOptions{Limit: 50})+ if err != nil {+ t.Fatal(err)+ }+ if total != len(seed)+1 || len(points) != total {+ t.Fatalf("correction removed history: total=%d, want %d", total, len(seed)+1)+ }+ byID := make(map[string]recovery.RecoveryPoint)+ for _, p := range points {+ byID[p.ID] = p+ }+ for _, original := range []recovery.RecoveryPoint{legacy, second, broken} {+ p, ok := byID[original.ID]+ if !ok || p.Outcome != recovery.OutcomeUnknown || p.CompletedAt != nil || p.StartedAt != nil {+ t.Errorf("legacy collection still claims completion: %+v", p)+ }+ if p.SizeBytes == nil || *p.SizeBytes != 1234 || p.SubjectRef.ID != original.SubjectRef.ID {+ t.Errorf("correction lost artifact evidence: %+v", p)+ }+ if original.ID != broken.ID {+ if p.Details["retained"] != "artifact-evidence" || p.Details["legacyCollectedAtMs"] != float64(original.CompletedAt.UnixMilli()) {+ t.Errorf("lost prior collection evidence: %+v", p.Details)+ }+ }+ }+ for _, original := range controls {+ p := byID[original.ID]+ if p.CompletedAt == nil || !p.CompletedAt.Equal(*original.CompletedAt) || p.Outcome != original.Outcome {+ t.Errorf("correction changed unrelated/native point %s: %+v", original.ID, p)+ }+ }+ assertUndatedTrueNASRollupAndSeries(t, db, legacy)+ var raw string+ if err := db.db.QueryRow(`SELECT details_json FROM recovery_points WHERE id = ?`, broken.ID).Scan(&raw); err != nil {+ t.Fatal(err)+ }+ if raw != "{broken" {+ t.Errorf("rewrote corrupt evidence: %q", raw)+ }+ if err := db.Close(); err != nil {+ t.Fatal(err)+ }+ }+}++func assertUndatedTrueNASRollupAndSeries(t *testing.T, db *Store, point recovery.RecoveryPoint) {+ t.Helper()+ opts := recovery.ListPointsOptions{RollupID: recovery.SubjectKeyForPoint(point), Limit: 50}+ rollups, total, err := db.ListRollups(context.Background(), opts)+ if err != nil {+ t.Fatal(err)+ }+ if total != 1 || len(rollups) != 1 {+ t.Fatalf("undated artifact lost rollup identity: %d/%d", total, len(rollups))+ }+ r := rollups[0]+ if r.LastSuccessAt != nil || r.LastAttemptAt != nil || r.LastVerifiedAt != nil || r.LastOutcome != recovery.OutcomeUnknown {+ t.Errorf("undated snapshot gained rollup timestamps/success: %+v", r)+ }+ series, err := db.ListPointsSeries(context.Background(), opts, 0)+ if err != nil {+ t.Fatal(err)+ }+ for _, day := range series {+ if day.Total != 0 {+ t.Errorf("undated snapshot created dated activity: %+v", day)+ }+ }+}++func ptrInt64Store(value int64) *int64 { return &value }diff --git a/internal/recovery/store/truenas_snapshot_times.go b/internal/recovery/store/truenas_snapshot_times.gonew file mode 100644index 0000000000..2d72623b2e--- /dev/null+++ b/internal/recovery/store/truenas_snapshot_times.go@@ -0,0 +1,24 @@+package store++// correctTrueNASSnapshotCollectionTimes removes a former mapper's synthetic+// completion date. That mapper always paired native creation dates with a+// start date; only its collection-time fallback had a completion but no start.+// Keep every artifact ID, reference and row. Retain the old value explicitly as+// legacy collection evidence, never as a native creation or successful backup.+// This is idempotent and runs before any reads or posture backfill on open.+func (s *Store) correctTrueNASSnapshotCollectionTimes() error {+ _, err := s.db.Exec(`+ UPDATE recovery_points+ SET details_json = CASE WHEN json_valid(details_json) THEN+ CASE WHEN json_type(details_json) = 'object' THEN+ json_set(details_json, '$.legacyCollectedAtMs', completed_at_ms)+ ELSE details_json END+ ELSE details_json END,+ completed_at_ms = NULL,+ outcome = 'unknown'+ WHERE provider = 'truenas' AND kind = 'snapshot' AND mode = 'snapshot'+ AND outcome = 'success' AND started_at_ms IS NULL+ AND completed_at_ms IS NOT NULL+ `)+ return err+}