···140140 return nil
141141}
142142143143+// extractCreatedAt attempts to extract createdAt timestamp from various record types
144144+func extractCreatedAt(recordValue any) time.Time {
145145+ // Try known types with createdAt fields
146146+ switch v := recordValue.(type) {
147147+ case map[string]any:
148148+ // Generic map fallback (shouldn't happen with lexutil but just in case)
149149+ if createdAtStr, ok := v["createdAt"].(string); ok {
150150+ if parsed, err := time.Parse(time.RFC3339, createdAtStr); err == nil {
151151+ return parsed
152152+ }
153153+ }
154154+ }
155155+156156+ // Try to extract via JSON marshal/unmarshal as last resort
157157+ // This works for any struct with a createdAt field
158158+ jsonBytes, err := json.Marshal(recordValue)
159159+ if err == nil {
160160+ var generic map[string]any
161161+ if err := json.Unmarshal(jsonBytes, &generic); err == nil {
162162+ if createdAtStr, ok := generic["createdAt"].(string); ok {
163163+ if parsed, err := time.Parse(time.RFC3339, createdAtStr); err == nil {
164164+ return parsed
165165+ }
166166+ }
167167+ }
168168+ }
169169+170170+ // Default to current time if no createdAt found
171171+ return time.Now()
172172+}
173173+143174// BootstrapFromRepo generates synthetic events from all current records in the repo
144175// This is called once when deploying persistent events to an existing repo
145176func (b *EventBroadcaster) BootstrapFromRepo(pds *HoldPDS) error {
···212243 collection := strings.Join(parts[:len(parts)-1], "/")
213244 rkey := parts[len(parts)-1]
214245246246+ // Extract createdAt timestamp from record if it exists
247247+ // Try to extract from known record types with createdAt fields
248248+ recordTime := extractCreatedAt(recordValue)
249249+215250 // Create synthetic RepoOp
216251 ops := []RepoOp{
217252 {
···254289 b.eventSeq++
255290 seq := b.eventSeq
256291 commitEvent := b.convertToCommitEvent(repoEvent, seq)
292292+293293+ // Override event time with record's original createdAt
294294+ commitEvent.Time = recordTime.Format(time.RFC3339)
257295258296 // Persist to database
259297 if err := b.persistEvent(commitEvent); err != nil {