// HOME, SIGN-IN, BACKUP AND SYNC, AS THE CORE ANSWERS THEM (`shell.home`; // boundary review move 5, 5 Nov 2026): the gate's stage, its words, its ways // out and where a refusal stands; where this device stands with its personal // object; the backup's count; the sync line; this device's copy; its acts in // order; Home's notices. The shell draws this and decides none of it. Plain // JSON, the same answer a Kotlin shell reads. // // Asked on launch, on every `{phase: home}` frame the core raises (the open // ending, and once a second while the gate waits: the clock's cadence), on a // data event, and after a sign-in, a sign-out or an erase. Never per frame. import Foundation extension CottonMethod { /// `shell.home {retry?, refusal?, device_name?}` — the gate, the stand, /// the backup, the sync line, this device, its acts and Home's notices, /// answered whole. `retry: true` begins a new wait and a new open; /// `refusal` is a code the app holds before the core can (the Keychain's); /// `device_name` files this phone in the database the core starts on a /// device holding none — there is no first-open choice. public static let shellHome = "shell.home" } public struct HomeAnswer: Decodable, Equatable, Sendable { public let gate: Gate /// `local`, `connecting`, `connected`, `backing_up` or `failed`. public let stand: String public let backup: Backup public let sync: Sync public let device: Device? public let acts: [Act] public let notices: [Notice] /// While a signed-in copy's first pull runs, the core's words saying the /// person's things are on their way: an app with nothing to show yet /// draws these, never its empty screen (launch-fast, 20 Nov 2026). public let bringing: Bringing? /// `{ words, line, percent, done, total, then }`: the one progress line /// every app draws (WORDS-PROGRESS-STORAGE.md §2): `words` whole /// ("Loading your data… 42%, then your photos"), `percent` filling its /// thin bar, or the bar moving on its own while `percent` is nil. public struct Bringing: Decodable, Equatable, Sendable { public let words: String public var line: String? public var percent: Int? public var done: Int? public var total: Int? public var then: String? public init(words: String, line: String? = nil, percent: Int? = nil, done: Int? = nil, total: Int? = nil, then: String? = nil) { self.words = words self.line = line self.percent = percent self.done = done self.total = total self.then = then } } public struct Gate: Decodable, Equatable, Sendable { /// `wait`, `opening`, `stalled`, `door` (a business app's device /// holding no database), `refused`, `moving`, `move_failed`, `failed` /// or `open`. public let stage: String public let code: String? /// `wall`, `banner` or `none`. public let refusal: String public let erase: Bool public let beat: Int public let words: Words public let progress: Progress? public let ways_out: [WayOut] } public struct Words: Decodable, Equatable, Sendable { public let reason: String? public let title: String? public let body: String? public let detail: String? public let usually: String? public let note: String? public let clock: String? public let progress: String? } public struct Progress: Decodable, Equatable, Sendable { public let done: Int public let total: Int } public struct WayOut: Decodable, Equatable, Sendable { public let id: String public let label: String /// `ink`, `line` or `red`. public let weight: String } public struct Backup: Decodable, Equatable, Sendable { public let sent: Int public let of: Int public let line: String } public struct Sync: Decodable, Equatable, Sendable { /// `alone`, `idle`, `syncing`, `waiting`, `failed` or `offline`. public let state: String public let line: String /// The line's typed state (`up_to_date`, `not_reached`, …). public let line_state: String? /// Changes waiting to go up. public let counter: Int public let failures: Int } public struct Device: Decodable, Equatable, Sendable { public let id: String? public let copy_bytes: Int? public let rows: Int? public let caught_up_at: String? } public struct Act: Decodable, Equatable, Sendable { public let id: String public let label: String /// `main`, `more` or `away`. public let rank: String public let red: Bool } public struct Notice: Decodable, Equatable, Sendable { public let id: String public let words: String /// `quiet`, `amber`, `refusal` or `done`. public let kind: String } }