|
| 1 | +// |
| 2 | +// SyncSnapshot.swift |
| 3 | +// CortexOS |
| 4 | +// |
| 5 | +// Single-call sync model — everything a client needs in one pull. |
| 6 | +// Backend is source of truth. Clients decode this on launch. |
| 7 | +// |
| 8 | + |
| 9 | +import Foundation |
| 10 | + |
| 11 | +// MARK: - Snapshot |
| 12 | + |
| 13 | +struct SyncSnapshot: Codable { |
| 14 | + let profile: SyncProfile |
| 15 | + let activeProject: ProjectContext? |
| 16 | + let priorities: PriorityBrief? |
| 17 | + let recentDecisions: [SyncDecision] |
| 18 | + let insights: [SyncInsight] |
| 19 | + let signals: [SyncSignal] |
| 20 | + let workingMemory: SyncWorkingMemory |
| 21 | + let syncedAt: String |
| 22 | + |
| 23 | + enum CodingKeys: String, CodingKey { |
| 24 | + case profile, priorities, insights, signals |
| 25 | + case activeProject = "active_project" |
| 26 | + case recentDecisions = "recent_decisions" |
| 27 | + case workingMemory = "working_memory" |
| 28 | + case syncedAt = "synced_at" |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +// MARK: - Profile (subset for sync) |
| 33 | + |
| 34 | +struct SyncProfile: Codable { |
| 35 | + let name: String |
| 36 | + let role: String |
| 37 | + let goals: [String] |
| 38 | + let interests: [String] |
| 39 | + let currentProjects: [String] |
| 40 | + let ignoredTopics: [String] |
| 41 | + |
| 42 | + enum CodingKeys: String, CodingKey { |
| 43 | + case name, role, goals, interests |
| 44 | + case currentProjects = "current_projects" |
| 45 | + case ignoredTopics = "ignored_topics" |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +// MARK: - Project |
| 50 | + |
| 51 | +struct ProjectContext: Codable { |
| 52 | + let projectName: String |
| 53 | + let currentMilestone: String |
| 54 | + let activeBlockers: [String] |
| 55 | + let recentDecisions: [String] |
| 56 | + let architectureNotes: [String] |
| 57 | + let openQuestions: [String] |
| 58 | + |
| 59 | + enum CodingKeys: String, CodingKey { |
| 60 | + case projectName = "project_name" |
| 61 | + case currentMilestone = "current_milestone" |
| 62 | + case activeBlockers = "active_blockers" |
| 63 | + case recentDecisions = "recent_decisions" |
| 64 | + case architectureNotes = "architecture_notes" |
| 65 | + case openQuestions = "open_questions" |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +// MARK: - Priority Brief |
| 70 | + |
| 71 | +struct SyncPriority: Codable, Identifiable { |
| 72 | + var id: String { title } |
| 73 | + let rank: Int |
| 74 | + let title: String |
| 75 | + let whyItMatters: String |
| 76 | + let nextStep: String |
| 77 | + let source: String |
| 78 | + let relevanceScore: Double |
| 79 | + let tags: [String] |
| 80 | + |
| 81 | + enum CodingKeys: String, CodingKey { |
| 82 | + case rank, title, source, tags |
| 83 | + case whyItMatters = "why_it_matters" |
| 84 | + case nextStep = "next_step" |
| 85 | + case relevanceScore = "relevance_score" |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +struct PriorityBrief: Codable { |
| 90 | + let date: String |
| 91 | + let priorities: [SyncPriority] |
| 92 | + let ignored: [String] |
| 93 | + let emergingSignals: [String] |
| 94 | + let changesSinceYesterday: [String] |
| 95 | + |
| 96 | + enum CodingKeys: String, CodingKey { |
| 97 | + case date, priorities, ignored |
| 98 | + case emergingSignals = "emerging_signals" |
| 99 | + case changesSinceYesterday = "changes_since_yesterday" |
| 100 | + } |
| 101 | +} |
| 102 | + |
| 103 | +// MARK: - Decision |
| 104 | + |
| 105 | +struct SyncDecision: Codable, Identifiable { |
| 106 | + let id: String |
| 107 | + let decision: String |
| 108 | + let reason: String |
| 109 | + let project: String |
| 110 | + let assumptions: [String] |
| 111 | + let contextTags: [String] |
| 112 | + let createdAt: String |
| 113 | + let outcome: String |
| 114 | + let impactScore: Double |
| 115 | + |
| 116 | + enum CodingKeys: String, CodingKey { |
| 117 | + case id, decision, reason, project, assumptions, outcome |
| 118 | + case contextTags = "context_tags" |
| 119 | + case createdAt = "created_at" |
| 120 | + case impactScore = "impact_score" |
| 121 | + } |
| 122 | +} |
| 123 | + |
| 124 | +// MARK: - Insight |
| 125 | + |
| 126 | +struct SyncInsight: Codable, Identifiable { |
| 127 | + let id: String |
| 128 | + let title: String |
| 129 | + let summary: String |
| 130 | + let whyItMatters: String |
| 131 | + let architecturalImplication: String |
| 132 | + let nextAction: String |
| 133 | + let confidence: Double |
| 134 | + let tags: [String] |
| 135 | + let relatedProject: String |
| 136 | + let createdAt: String |
| 137 | + |
| 138 | + enum CodingKeys: String, CodingKey { |
| 139 | + case id, title, summary, confidence, tags |
| 140 | + case whyItMatters = "why_it_matters" |
| 141 | + case architecturalImplication = "architectural_implication" |
| 142 | + case nextAction = "next_action" |
| 143 | + case relatedProject = "related_project" |
| 144 | + case createdAt = "created_at" |
| 145 | + } |
| 146 | +} |
| 147 | + |
| 148 | +// MARK: - Signal |
| 149 | + |
| 150 | +struct SyncSignal: Codable, Identifiable { |
| 151 | + let id: String |
| 152 | + let topic: String |
| 153 | + let frequency: Int |
| 154 | + let strength: Double |
| 155 | + let status: String // emerging, confirmed, fading, archived |
| 156 | + let firstSeen: String |
| 157 | + let lastSeen: String |
| 158 | + let sourceTitles: [String] |
| 159 | + |
| 160 | + enum CodingKeys: String, CodingKey { |
| 161 | + case id, topic, frequency, strength, status |
| 162 | + case firstSeen = "first_seen" |
| 163 | + case lastSeen = "last_seen" |
| 164 | + case sourceTitles = "source_titles" |
| 165 | + } |
| 166 | +} |
| 167 | + |
| 168 | +// MARK: - Working Memory |
| 169 | + |
| 170 | +struct SyncWorkingMemory: Codable { |
| 171 | + let date: String |
| 172 | + let todaysPriorities: [String] |
| 173 | + let currentlyExploring: [String] |
| 174 | + let temporaryNotes: [String] |
| 175 | + |
| 176 | + enum CodingKeys: String, CodingKey { |
| 177 | + case date |
| 178 | + case todaysPriorities = "todays_priorities" |
| 179 | + case currentlyExploring = "currently_exploring" |
| 180 | + case temporaryNotes = "temporary_notes" |
| 181 | + } |
| 182 | +} |
0 commit comments