// THE COUNTER SAYS WHAT A TOOL'S ROWS ARE DOING (owner, 2 Nov 2026): the// deck's counter top-left ("1 / 135") says, while rows of the showing tool's// table are arriving or leaving, what is happening — "347 of 950 todos// arriving", "25 todos sending" — and is the plain count again once the// table is settled. Same place, same type, same ink; no new control. So Home// can go later; Home stays the one sync card for now.//// The core decides: This Device's live read (`device.facts`, the read Home's// device card draws) carries `sync_table_progress`, each table that is moving// by its id — `arriving`/`arrived` while the pass has rows of it to come,// `sending` while this phone has writes of it queued — and names no settled// table. The words are the kit's (`cards.deck.moving`).importCottonKitimportCottonValuesimportFoundation/// What the showing table's rows are doing.enumDeckMoving: Equatable {/// Nothing of it is moving: the plain count.case settled/// The pass has rows of it still to come: `arrived` of `arriving` have.case arriving(arrived: Int, of: Int)/// This phone has `n` writes of it waiting to go up.case sending(Int)/// `table`'s state in `progress` (`sync_table_progress`): arriving before/// sending, as rows coming is what the deck is short of.staticfunc of(_ table: String, in progress: RecordValue?) -> DeckMoving {guardcase .object(let tables)? = progress, case .object(let moving)? = tables[table] else { return .settled }func count(_ key: String) -> Int? {ifcase .number(let n)? = moving[key] { returnInt(n) }returnnil }iflet of = count("arriving"), let arrived = count("arrived"), arrived < of { return .arriving(arrived: arrived, of: of) }iflet n = count("sending"), n > 0 { return .sending(n) }return .settled }/// Whether the counter reads again after reading `now`: while the table/// moves, and while a pass is in flight — its pages land inside one/// cycle, so its first read comes before the object has said a table's/// figures (walk 3, 2 Nov 2026: a read that stopped at "settled" never/// saw the rows arriving).staticfunc readsAgain(_ now: DeckMoving, passing: Bool) -> Bool { now != .settled || passing }/// The counter's words for this state, of a table named `name` (one)/// and `plural`; nil when settled — the plain count stands.func line(name: String, plural: String) -> String? {let one = name.lowercased(), many = plural.lowercased()switchself {case .settled:returnnilcase .arriving(let arrived, let of):returnShellLines.line("cards", of == 1 ? "deck.moving.arriving_one" : "deck.moving.arriving", ["at": String(arrived), "of": String(of), "name": one, "plural": many])case .sending(let n):returnShellLines.line("cards", n == 1 ? "deck.moving.sending_one" : "deck.moving.sending", ["n": String(n), "name": one, "plural": many]) } }}enumDeckMovingKnobs {/// Seconds between reads while the showing table is moving.staticlet every: Double = 1.5}/// This Device's `sync_table_progress`, as its live read says it now; nil/// when this build does not sync or the read fails (the plain count stands).enumDeckMovingRead {privatestructFacts: Decodable { let data: [String: RecordValue] }/// Whether this build syncs at all: Rigby keeps no object and reads none.staticlet syncs = FlavourManifest.current?.sync ?? false @MainActor privatestaticvar thisDevice: String? @MainActor staticfunc read(_ core: (any CottonCalling)?) async -> RecordValue? {guard syncs, let core else { returnnil }if thisDevice == nil { thisDevice = (try? await core.callJSON(CottonMethod.readDevices))?.untrimmed("thisDevice") }guardlet id = thisDevice,let facts = try? await core.call(CottonMethod.deviceFacts, ["deviceId": RecordValue.text(id)], as: Facts.self)else { returnnil }return facts.data["sync_table_progress"] }}