// People's traffic and money, at the boundary: the read NAMES 4g's screens ask // for, the two non-read methods the surface calls, and the one rule about // money that every reader shares. // // The SHAPES are not here any more (I3). A `read.*` answer is a `JSONValue` // tree the screen reads with the scaffold's accessors (`text`, `number`, // `list`, `minor`, …), and `ReadKeySweepTests` holds every key literal a screen // spells against the `json!` keys the crate writes. A method name is still a // wire string and a typo is still an `unknown_method` at RUNTIME, so // `BoundaryContract4gTests` reads `phone/reads.rs` by path and refuses a name // the crate does not declare — which is why every name below lives in ONE file // rather than beside its screen. The `Encodable` request structs each read // takes live beside the screen that sends them. // // **Where this file and `crates/cotton-ffi/src/phone/reads.rs` disagree, the // crate wins.** import Foundation extension CottonMethod { // ── The reads 4g declares for email ─────────────────────────────────── /// `/email` — the folder, both ways round. /// /// Optional `folder` (`inbox` · `archived` · `bin` · `all`), which /// **defaults to `inbox` in the crate** rather than to the tool's own /// `all`, and an optional `sender` address forwarded to the THREAD list /// only. Answers the folder echoed back, the threads, and the /// same folder counted by sender. /// /// One read rather than two because the screen's segment control is a LOCAL /// flip between two lists over the same rows — asking for them separately /// would read the mailbox twice for one tap. /// /// **Both halves are capped at 200 by the crate**, stated rather than /// defaulted. The mailbox used to be unbounded — neither list took a limit /// at all — so a mailbox past two hundred threads, or two hundred senders, /// is short at its old end here. public static let readEmail = "read.email" } extension CottonMethod { // ── The one read this family declares ───────────────────────────────── // // The films' library is `read.photos` (one library, `phone/traffic.rs:: // photos` answers `videos` beside `photos`); `/videos` redirects onto it. /// `/settings#storage` — what CottonDB is using on THIS phone. /// /// `phone/reads.rs::storage`, a `ReadSource::Controller` because the answer /// is not in the database at all: it is the data directory's own size, read /// through the injected `phone::disk::Disk` seam, plus the device-local /// `_media` ledger's counts and its rows. /// /// **This is NOT `storage_summary`.** That tool adds up the WORKSPACE's own /// record rows — a true and useful number about the database that says /// nothing about the device the screen is running on. A person opening this /// screen is asking how much of THEIR PHONE Cotton is using. public static let readStorage = "read.storage" // ── The byte-locating method 4p landed, and where its twin lives ────── // ``CottonMethod/readMediaPath`` is NOT declared here. 4i named it first, // in `Boundary+4i.swift`, for the same reason this file would have — a // read named only beside its screen is invisible to the boundary tests, so // a crate-side rename reaches the app as an `unknown_method` at runtime // instead of as a red test. Two lanes each claiming to be its one home is // a redefinition and does not compile, which is how the merge said so. // `media.ensure` below has no other claimant and stays here. /// `media.ensure` — the path, fetching the bytes first if they are not /// here. /// /// `phone/media.rs::ensure`. Takes `{key}`; answers `{path, fetched}`. /// **It refuses by name today**: nothing has filled the crate's /// `MediaFetch` seam, so a key whose bytes are not already on this device /// comes back `no_media_fetch` with the crate's own sentence. That is /// today's behaviour and it ports as is — the screen shows the sentence and /// draws the absent state. /// /// Declared here for the reason ``readMediaPath`` is declared in /// `Boundary+4i.swift`: a method named only beside its screen is invisible /// to `BoundaryContractTests`. public static let mediaEnsure = "media.ensure" /// `media.viewed` — a detail view opened an original. /// /// `phone/media.rs::viewed`. Takes `{key}`; answers `{viewed}`, which is /// `false` for a key the ledger does not have and is not an error. /// /// **A grid must never call this.** It is the stamp the budgeted cache /// orders by: the phone keeps viewed originals under a budget and takes the /// least recently viewed first, so a stamp written by a scrolling finger /// would make "least recently viewed" mean "least recently scrolled past" — /// and the phone would drop exactly the pictures somebody keeps opening. /// The two callers are the full-screen photo viewer, on a tap, and the film /// page, which opening IS the asking. public static let mediaViewed = "media.viewed" /// `media.uploads` — where each of these files is on its way up. /// /// `phone/media.rs::uploads` (MEDIA DRAIN 1). Takes `{keys}` (at most /// 10,000); answers `{files: [{key, phase, sent?, total, code?, line?, /// attempts, nextTryAt?, network, askedBy?}], counts}` in the order asked. /// `uploaded` is the object's own answer, per file; `failed` carries the /// word the person acts on (`too_big`, `cotton_full`, `file_gone`, /// `refused`). Reads the ledger and the uploads in the air, never the /// network. public static let mediaUploads = "media.uploads" /// `media.network` — the network the phone is on now. /// /// `phone/media.rs::network` (MEDIA DRAIN 1 item 2). Takes `{path}`: /// `wifi`, `mobile`, `constrained` (Low Data Mode) or `none`; said at /// launch and on every change. A file queued for Wi-Fi only waits until /// the core has heard `wifi`. public static let mediaNetwork = "media.network" /// `media.stream` — a film's HLS master or whole file, a book's or a /// song's file, signed at the object. /// /// `phone/films.rs`. Takes `{key}`; answers `{url, expires_at}`: the /// address Apple's player reads with no bearer, and every playlist and /// segment under it, for twelve hours. public static let mediaStream = "media.stream" /// `films.here.read` — what this phone keeps of a film's file: the /// bundle a stream was kept as, or a whole file kept in the media store. /// `{key}` → `{key, bookmark, state}`. Where a film was stopped is not /// here: it is the record's `position`. public static let filmsHereRead = "films.here.read" /// `films.here.write` — the same, written: `{key, state, bookmark?, /// from?}`, `state` keeping, kept or `null`; a kept whole file names the /// downloaded file (`from`). Never synced. public static let filmsHereWrite = "films.here.write" /// `films.remove` — a whole film's Remove download: this phone's copy /// goes (never the last one). `{key}` → `{key, freed_bytes}`. public static let filmsRemove = "films.remove" /// `films.keeping` — this phone's keeping knobs: `{}` → /// `{keep_everything, cellular, budget_gb}`. public static let filmsKeeping = "films.keeping" /// `films.onPhone` — what this phone keeps, for On this phone's top /// line: `{}` → `{films, series, bytes}` (a stream's bundle is the /// platform's to measure). public static let filmsOnPhone = "films.onPhone" /// `films.capture` — films as the phone read them, at most 200 at a time: /// `{films: [{path, sourcePath, minutes?, video?, audio?, height?, /// bitrate?, title?, year?, posterPath?, locked?}], onlyFilms?}` → /// `{films: [{sourcePath, outcome, id?, key?, table?, needsMac?, title, /// line}], said}`. public static let filmsCapture = "films.capture" /// `episodes.here.read` — what this phone keeps of a podcast episode, by /// its audio address. `{url}` → `{url, state, file}`. Never synced. public static let episodesHereRead = "episodes.here.read" /// `episodes.here.write` — the same, written: a field given is set, /// `null` clears it; `kept` names its file. public static let episodesHereWrite = "episodes.here.write" /// `books.here.read` — what this phone keeps of a book, by its file's /// key. `{key}` → `{key, state}`. Never synced. public static let booksHereRead = "books.here.read" /// `books.here.write` — the same, written: `keeping`, `kept` (the bytes /// are here; the core pins them against the budget), or `null`. public static let booksHereWrite = "books.here.write" /// `books.remove` — Remove download: this phone's copy of one book's file /// goes (never the last copy), and what it kept of it is forgotten. /// `{key}` → `{key, freed_bytes}`. public static let booksRemove = "books.remove" /// `books.folder` — Add a folder: every file of the picked tree, staged /// (`path`) and named by its path below the folder, `/` between parts /// (`name`). `{files: [{path, name}]}` → `{books: [{id, title, outcome /// (added | already | refused), why?}], skipped: [name], words}`; a /// folder holding no book is refused, in words. public static let booksFolder = "books.folder" /// `media.share` — a file's Share: its bytes fetched to this phone when /// they are not here. `{key}` → `{platform_action: share_file, path}`. public static let mediaShare = "media.share" /// `object.act` — an act at the person's own object, through the core /// (which alone holds the bearer): `{act, args}` → the object's answer. /// Only the acts the core admits (a podcast's subscribe and refresh). public static let objectAct = "object.act" public static let shareFetchLinks = "share.fetchLinks" /// `music.capture` — one album's songs as the phone read them, made in /// one write: `{songs: [{path, sourcePath, tags, coverPath?, entry?}], /// zip?}` → `{songs: [{sourcePath, outcome, id?, key?, title, line}], /// said, album?}`. With `zip` (`music.zip`'s answer) they are one album. public static let musicCapture = "music.capture" /// `music.zip` — an album ZIP's songs, cover, booklet and notes streamed /// out: `{path, name, into}` → `{songs: [{entry, path, sourcePath}], /// coverPath?, bookletPath?, storeUrl?, storeId?, boughtOn?}` or /// `{refused, line}`. public static let musicZip = "music.zip" public static let musicFill = "music.fill" /// `songs.here.read` / `songs.here.write` / `songs.remove` — what this /// phone keeps of one song's file, as `books.here.*` for a book's. public static let songsHereRead = "songs.here.read" public static let songsHereWrite = "songs.here.write" public static let songsRemove = "songs.remove" /// `songs.keepEverything` — this phone's Keep everything: `{on?}` → `{on, said?}`. public static let songsKeepEverything = "songs.keepEverything" } extension CottonMethod { /// `/messages` — the inbox, ONE ROW PER THREAD. /// /// `groupBy: "thread"` is forced below the boundary, so the person-merge is /// the screen's. Takes `archived` (a /// BOOL; anything else reads as `false`) and answers the other half of the /// list plus the count that opens it. The tool's ceiling is 200 threads and /// the archived split happens AFTER it — past two hundred conversations the /// inbox comes back short, which the crate's own comment records. public static let readThreads = "read.threads" } extension CottonMethod { /// `/photos` — the whole library, pictures (`photos`) AND films /// (`videos`), each newest first, plus the albums and the two review /// COUNTS the screen's menu offers. public static let readPhotos = "read.photos" } extension CottonMethod { /// `meetings.create` — a recording becomes a meeting (`phone/meetings.rs`). /// /// **The one door.** The MCP surface says meetings "enter by recording or /// import on the phone", and `capture.media` refuses `meeting` by name /// because a meeting's audio belongs to a row with a STATUS the server's /// pipeline walks. This method is that row's only producer. /// /// Takes `path` (the audio file, which stays on the phone — bytes never /// cross the boundary, and the crate COPIES it into the media store so the /// caller discards its own copy), `source` (`record` or `import`), and the /// optional `title`, `startedAt` (RFC3339), `durationMs` and `mime`. /// Answers `{id, route, key}` — the new meeting, the screen to land on /// (`/meetings/meeting/`), and the object its audio went to. /// /// The row is born at `uploading` and NOTHING waits on the upload: the /// `_media` ledger carries it and the server queues the meeting once the /// bytes are in the store. The container follows the file — a WhatsApp /// voice note is `full.opus`, not an m4a that lies about its own bytes. public static let meetingsCreate = "meetings.create" } extension CottonMethod { }