Cotton code
3420 lines · 122.0 KB · RustRaw
//! The method table — everything the app can ask, inside ONE C function.//!//! Design M1: the ABI is six functions and stays six for the life of the app,//! because every capability is a METHOD NAME here. Adding one never touches the//! header, the module map or the build.//!//! The answer envelope is the same for every method://!//! ```json//! { "ok": true,  "data": … }//! { "ok": false, "error": { "code": "…", "message": "…", "details": { … } } }//! ```//!//! An error is a value, never a panic and never a crash: a refusal the app can//! draw beats a boundary that takes the person's server down with it./// A Mac's own host settings on its Device page; the read half is shared.pub mod first_push;pub mod host_settings;/// The device and member page acts' receipts and undo (Spec 11 (c)).pub mod page_acts;pub mod card_pages;/// The ink above the fan, read in the core (`cotton_core::ink`).pub mod ink;pub mod shell_deck;pub mod shell_deck_player;pub mod shell_fan;pub mod shell_rail;pub mod shell_stream;pub mod shell_input;mod shell_input_business;pub mod shell_account;pub mod shell_settings;pub mod shell_home;pub mod shell_today;pub mod shell_reading;pub mod shell_lines;pub mod shell_list;pub(crate) mod shell_slip;pub(crate) mod shell_kept;pub(crate) mod shell_order;pub(crate) mod shell_plan;pub mod sync;use serde_json::{json, Value};use crate::handle::CottonHandle;/// What a method answers when it cannot answer.#[derive(Debug, Clone, PartialEq, Eq)]pub struct MethodError {    pub code: String,    pub message: String,    pub details: Value,}impl MethodError {    pub fn new(code: &str, message: impl Into<String>) -> Self {        let message = message.into();        let code = if message == cotton_core::genesis::NO_PERSONAL_MESSAGE {            cotton_core::genesis::NO_PERSONAL_DATABASE_IN_FLAVOUR        } else {            code        };        Self {            code: code.to_string(),            message,            details: Value::Null,        }    }    pub fn with_details(mut self, details: Value) -> Self {        self.details = details;        self    }    /// This failure as the person reads it (R6): its message when it is a    /// sentence for them, else the plain sentence for what did not happen,    /// with the raw message handed back for the log — never for a screen.    pub fn for_person(self) -> (Self, Option<String>) {        use cotton_core::failure::{for_person, Act};        // A cut read is drawn from its definition's typed line        // (`words.could_not_read[details.why]`); its message is the log's        // alone, so a transport's words never cross to a page, however        // plain they read (294 walk row G).        if self.code == COULD_NOT_READ {            let logged = format!("{}: {}", self.code, self.message);            return (                Self {                    message: Act::Read.sentence().to_string(),                    ..self                },                Some(logged),            );        }        let act = match self.code.as_str() {            "write_refused" | "store" => Act::Keep,            "unreadable" | "record_not_found" => Act::Read,            _ => Act::Other,        };        let said = for_person(&self.message, act);        let logged = said.logged.map(|raw| format!("{}: {raw}", self.code));        (            Self {                message: said.sentence,                ..self            },            logged,        )    }    pub fn envelope(&self) -> Value {        json!({            "ok": false,            "error": {                "code": self.code,                "message": self.message,                "details": self.details,            }        })    }}/// EVERY method name this core knows — the list the guards in this module are/// written against. A method absent from it answers `unknown_method` by/// construction rather than through a stub that lies about what happened.pub const ALL_METHODS: &[&str] = &[    "days.export",    "days.span",    "days.month",    "days.sometime",    "days.groups",    "days.item",    "days.change",    "days.done",    "days.undone",    "days.skip",    "days.move",    "days.read_line",    "days.add",    "days.marks",    "days.marks.find",    "days.google",    "days.google_disconnect",    "bootstrap.start",    "bootstrap.status",    "build.facts",    "camera.shot",    "calls.answer",    "calls.decline",    "calls.end",    "calls.history",    "calls.speaking",    "calls.mute",    "calls.leave",    "calls.invite",    "calls.join",    "calls.ack",    "calls.iceServers",    "calls.incoming",    "calls.link",    "calls.media",    "calls.openLink",    "calls.pushToken",    "calls.signal",    "calls.socketClosed",    "calls.start",    "calls.state",    "calls.stop",    "calls.tick",    "chat.accept",    "chat.ahead",    "chat.blocked",    "chat.sms.here",    "chat.sms.land",    "chat.sms.outbox",    "chat.sms.sent",    "chat.contact",    "chat.contacts",    "chat.invite",    "chat.profile",    "chat.profile.set",    "chat.profilePicture",    "chat.act",    "chat.block",    "chat.call",    "chat.callScreen",    "chat.calls",    "chat.recording",    "chat.recording.act",    "chat.recording.live",    "chat.compose",    "chat.downloads",    "chat.downloads.act",    "chat.downloads.send",    "chat.file",    "chat.flush",    "chat.ground",    "chat.forget",    "chat.incoming",    "chat.keep",    "chat.key",    "chat.export",    "chat.link",    "chat.list",    "chat.mail",    "chat.mail.act",    "chat.mail.compose",    "chat.mail.countSender",    "chat.mail.discard",    "chat.mail.file",    "chat.mail.free",    "chat.mail.page",    "chat.mail.hold",    "chat.mail.save",    "chat.mail.send",    "chat.mail.sender",    "chat.mail.thread",    "chat.mail.trashSender",    "chat.notices",    "chat.picture",    "chat.preview",    "chat.previews",    "chat.ratchet",    "chat.receipt",    "chat.refuse",    "chat.register",    "chat.retry",    "chat.rows",    "chat.safety",    "chat.safety.scan",    "chat.safety.verify",    "chat.search",    "chat.sender.act",    "chat.sender.ask",    "chat.sender.page",    "chat.senders",    "chat.senders.blocked",    "chat.send",    "chat.settings",    "chat.slips",    "chat.socket",    "chat.starred",    "chat.storage",    "chat.storage.free",    "chat.start",    "chat.text",    "chat.theme",    "chat.theme.set",    "chat.themes",    "chat.thread",    "chat.timer.binned",    "chat.timer.erase",    "chat.timer.restore",    "chat.typing",    "chat.unblock",    "chat.warm",    "chat.waveform",    "chat.waveforms",    "chat.you",    "chat.you.now",    "mail.home",    "mail.list",    "mail.side",    "mail.thread",    "mail.page",    "mail.file",    "mail.free",    "mail.files",    "mail.search",    "mail.archive",    "mail.act",    "mail.undo",    "mail.after",    "mail.ask",    "mail.do",    "mail.bin.empty",    "mail.you",    "mail.set",    "mail.pictures.always",    "mail.link",    "mail.hold",    "mail.rules",    "mail.verdict",    "mail.senders",    "mail.sender",    "mail.sender.merge",    "mail.sender.part",    "mail.sender.name",    "mail.blocked",    "mail.unblock",    "mail.compose",    "mail.save",    "mail.discard",    "mail.attach",    "mail.unattach",    "mail.send",    "mail.unsend",    "mail.sending",    "mail.accounts",    "mail.account.plan",    "mail.account.add",    "mail.account",    "mail.account.way",    "mail.account.set",    "mail.account.forget",    "mail.account.remove",    "mail.fetch",    "mail.domains",    "mail.domain",    "mail.domain.add",    "mail.domain.remove",    "mail.domain.check",    "mail.domain.catch_all",    "mail.address.add",    "mail.address.remove",    "sites.add",    "sites.book.leave",    "sites.add.plan",    "sites.delete",    "sites.edit",    "sites.left",    "sites.link",    "sites.list",    "sites.open",    "sites.arrange",    "sites.block",    "sites.choose",    "sites.close",    "sites.exit",    "sites.failed",    "sites.fill",    "sites.forget",    "sites.home",    "sites.live",    "sites.login",    "sites.logins",    "sites.move.done",    "sites.move.in",    "sites.move.out",    "sites.panel",    "sites.save_to_words",    "sites.search",    "sites.set",    "sites.settings",    "sites.state",    "sites.storage",    "sites.trackers",    "sites.wait",    "sites.keep_one",    "sites.orphans.remove",    "sites.stores.gone",    "sites.stores.keep",    "sites.stores.removed",    "sites.undo",    "send.decline",    "send.inbox",    "send.keep",    "send.make",    "send.offer",    "send.picture",    "send.trust",    "send.undo",    "shared.add",    "shared.found",    "shared.lists",    "shared.put",    "shared.read",    "shared.remove",    "shared.take",    "capture.avatar",    "capture.media",    "shell.opened",    "cards.birthdays",    "cards.factLabels",    "cards.moneyDue",    "cards.repeat",    "cards.when",    "code.preferences.import",    "code.preferences.read",    "code.preferences.set",    "business.sync",    "business.pages",    "business.code",    "business.signIn",    "business.signOut",    "business.act",    "personal.ask",    "personal.askPoll",    "personal.handoff",    "personal.passkeyBegin",    "personal.passkeySignIn",    "personal.code",    "personal.signIn",    "personal.connect",    "personal.adopt",    "personal.adoptStatus",    "personal.standLocal",    "personal.remove",    "account.delete",    "account.deleteCode",    "account.deletePage",    "account.forget",    "account.keep",    "account.leave",    "restore.points",    "restore.begin",    "restore.progress",    "restore.cancel",    "restore.after",    "databases.create",    "databases.delete",    "databases.restore",    "databases.hide",    "databases.invite",    "databases.leave",    "databases.present",    "databases.remove",    "databases.show",    "databases.toolkits",    "datadir.status",    // THE TABLE AND TOOL DEFINITIONS, and the generic verbs below, answered by    // `phone::records` through the same handlers an MCP connection calls.    "definitions.board",    "definitions.catalogue",    "definitions.contributors",    "definitions.passedOver",    "definitions.resetBoard",    "definitions.saveBoard",    "definitions.saveTable",    "definitions.saveTheme",    "definitions.tables",    "definitions.theme",    "definitions.undoTheme",    "definitions.tools",    // Cotton Dev only: this phone's copy stamped as the build before this    // one wrote it — the release walk's schema bump under unsent changes.    "developer.stampStaleCopy",    // Cotton Dev only: a theme row as a newer build would sync it in.    "developer.wearThemeRow",    // Cotton Dev only: invented writing an assistant made (notes, web pages,    // memory), for a look at Words' Your assistant on a simulator.    "developer.inventAssistantWriting",    "developer.inventNoteFiles",    "developer.inventServedCopy",    "developer.cutNetwork",    // Cotton Dev only: kept chat pictures left plain as an app before 22 Nov 2026 kept them, and the check after the reseal.    "developer.inventKeptPictures",    "developer.checkKeptPictures",    "developer.resealKept",    // Cotton Dev only: invented mail for Comms (MAIL.md), on an emulator or an invented account as large as the owner's.    "developer.inventMail",    // Cotton Dev only: a delete for everyone the Mac's link would report, for a walk with no Mac (FEEDBACK-3).    "developer.revokeWhatsapp",    "developer.fakeMac",    // Cotton Dev only: WhatsApp chats whose people carry profile pictures, and a poll, as the Mac's link lands them.    "developer.inventWhatsappFaces",    // Cotton Dev only: invented senders across WhatsApp and SMS, for a walk of People (SENDERS.md).    "developer.inventSenders",    // Cotton Dev only: the iPhone's walk of People: senders on WhatsApp, by SMS and by mail, in one write.    "developer.inventPeopleWalk",    // Cotton Dev only: Look's table as a server before Look serves it (no type_face), for a face chosen there.    "developer.lookServedBefore",    // Cotton Dev only: two changes that cannot be sent, for a walk of the Sync page's Send again and Let go (UNSENT HEAL).    "developer.stuckChange",    "device.becomeRunner",    "device.facts",    "device.notifications.asked",    "device.notifications.openSettings",    "device.notifications.request",    "device.preferences.import",    "device.preferences.read",    "device.preferences.set",    "device.rekey",    "device.rekey.cancel",    "device.rekey.start",    "device.rekey.status",    "device.push",    "device.serveFrom",    "device.setSessions",    "device.setAiCap",    "device.testPush",    "device.pushAck",    "devices.approvePending",    "devices.declinePending",    "devices.list",    "devices.pending",    "devices.rename",    "devices.revoke",    "diagnostics.debug",    "diagnostics.removeCopy",    "diagnostics.report",    "diagnostics.say",    "dictation.create",    // THE OWNER'S ACTS ON A DOMAIN (`phone::domains`): a signed call to the    // serving Mac, which holds the Cloudflare token; run only as the Domains    // page's commands.    "domains.checkPrice",    "domains.handOver",    "domains.register",    "export.build",    "package.export",    "package.exportOpen",    "package.import",    "feedback.flush",    "feedback.send",    "usage.record",    // A film's stream address and what this device keeps of each film    // (`phone::films`): the object signs the one, the other never syncs.    "films.here.read",    "films.here.write",    // An admitted act at the person's object (`phone::object_acts`).    "object.act",    // What this device keeps of each book's file, its Remove download and    // Add a folder (`phone::books`); the reader opening one (`phone::reader`).    "books.here.due",    "books.here.read",    "books.here.write",    "books.remove",    "books.folder",    "reader.open",    "shell.reader",    "shell.reading",    "reader.moved",    "reader.highlight",    "reader.settings",    "reader.seek",    "reader.seek.say",    "reader.seek.go",    "reader.seek.back",    // Cotton Music (`phone::songs`): the intake, what this device keeps of    // each song's file, the one player (`phone::shell_player`: songs, podcast    // episodes and films) and an album's lookups.    "music.capture",    "music.zip",    "music.lists",    "songs.here.read",    "songs.here.write",    "songs.remove",    "songs.keepEverything",    "songs.keepPlan",    "shell.player",    "music.findDetails",    "music.fill",    // Android's song intake (`phone::song_intake`): which picked files are    // songs, the writes they gather into, what the intake came to.    "music.picked",    "music.gathered",    "music.landed",    // Cotton Cinemas (`phone::film_intake`, `phone::film_player`): the    // intake, Keep everything and a whole file's Remove download, and Mark    // watched. A film plays through `shell.player`.    // Cotton Money (`phone::money`): how its objects print an amount, Pay by    // UPI's deep link, and a statement brought in at Plus.    "money.print",    "money.upiPay",    "money.statements.capture",    "films.capture",    "films.picked",    // Give subtitles (`phone::film_subtitle_file`): a .srt or .vtt picked from the phone's files, kept sealed for the Mac.    "films.subtitleFile",    "films.keepEverything",    "films.remove",    "films.keeping",    "films.onPhone",    "cinemas.home",    "cinemas.row",    "cinemas.season",    "cinemas.search",    "cinemas.kind",    "cinemas.groups",    "cinemas.hide",    "cinemas.hidden",    "cinemas.unlock",    "cinemas.lock",    "cinemas.groupsOrder",    "groups.order",    "cinemas.title",    "cinemas.toEpisode",    "cinemas.subtitles",    "cinemas.onPhone",    "cinemas.preparing",    "cinemas.remote",    "cinemas.shared",    "cinemas.shared.leave",    "cinemas.bin",    "cinemas.restore",    "cinemas.erase",    "cinemas.you",    "cinemas.setting",    "films.keepPlan",    "films.mark",    // Cotton Health (`phone::health`): what HealthKit is asked for, the    // anchors kept per type, a batch landed, the export read, the summaries.    "health.anchor",    "health.held",    "health.land",    "health.readExport",    "health.summary",    "health.types",    // Cotton Health's screens (`phone::health_app`; shapes in `cotton_core::health::app::shapes`).    "health.act",    "health.addPerson",    "health.addReport",    "health.body",    "health.labs",    "health.look",    "health.metric",    "health.parameter",    "health.people",    "health.report",    "health.reports",    "health.settings",    // Cotton Story (`phone::story`): the writer's lines, Return and Tab, the    // element bar and names; a scene's writes and order; the current story;    // cards, the laid-out script and Fountain out and in (apps/story/CORE.md).    "story.answer",    "story.character.add",    "story.draft",    "story.interval",    "story.interview",    "story.line.add",    "story.line.edit",    "story.line.remove",    "story.line.move",    "story.person.lines",    "story.list",    "story.scene",    "story.scene.add",    "story.scene.place",    "story.scene.leave",    "story.scene.remove",    "story.scenes",    "story.sequence.add",    "story.sequence.edit",    "story.sequence.remove",    "story.skip",    "story.theme.set",    "story.themes",    "story.card",    "story.chat",    "story.choose",    "story.copy",    "story.current",    "story.figures",    "story.fountain.read",    "story.bring_in",    "story.fountain.write",    "story.kind",    "story.lines",    "story.names",    "story.press",    "story.rename",    "story.scene.duplicate",    "story.scene.move",    "story.scene.near",    "story.scene.new",    "story.scene.write",    "story.script",    "story.start",    "story.write",    "story.places",    "story.place",    "story.person",    "story.pictures",    "story.things",    "story.costumes",    "story.fdx.write",    "story.drafts.list",    "story.drafts.read",    "story.drafts.changes",    "story.scene.split",    "story.scene.merge",    "story.merge",    "story.picture.add",    "story.picture.remove",    "story.picture.move",    "story.drafts.mark",    "story.drafts.restore",    "google.connect",    "google.disconnect",    "google.status",    "signin.approve",    "signin.approveSibling",    "signin.asks",    "signin.passkeyAdd",    "signin.passkeyOptions",    "signin.passkeyRemove",    "signin.passkeys",    "signin.refuse",    "signin.show",    "signin.siblingTicket",    "gettingIn.again",    "gettingIn.screen",    "spotify.connect",    "spotify.disconnect",    "spotify.status",    "groups.create",    "groups.delete",    "groups.list",    "groups.update",    // THE SERVING PAGE'S CODE BLOCK (`methods::host_code`): what this Mac can    // run, and the folder it holds each project's repository in. Host methods    // because both answers are about a machine's own filesystem — a phone has    // no checkout and no home directory to judge a folder against.    "identity.get",    "import.whatsappExport",    "keep.audience",    "keep.clear",    "keep.open",    "keep.reconcile",    "keep.rules",    "keep.set",    // The KEYS page (`methods::keys`): the three the Mac answers over the    // provider keys in the person's vault. Never a tool, and never a value.    "log.lines",    "media.ensure",    "media.network",    "media.stream",    "media.uploads",    "media.viewed",    "meetings.action.todo",    "meetings.delete",    "meetings.export",    "meetings.import",    "meetings.language",    "meetings.line.correct",    "meetings.merge",    "meetings.next",    "meetings.note",    "meetings.read",    "meetings.record.discard",    "meetings.record.recover",    "meetings.record.start",    "meetings.record.stop",    "meetings.record.tick",    "meetings.search",    "meetings.speaker.name",    "meetings.summarise",    "meetings.title",    "meetings.transcribe",    "meetings.transcribed",    "meetings.windows",    "media.describe",    "media.share",    "members.admit",    "members.claimPerson",    "migrate.status",    "page.save",    "share.fetchLinks",    "share.door",    "link.open",    // Cotton Notes (`phone::notes`): the list, the fan, the writer's text,    // spans and buttons, tags as groups, archive and bin, look and type, and    // Bring notes in (cotton_rules::writing).    "notes.archive",    "notes.bin",    "notes.edit",    "notes.empty_bin",    "notes.export",    "notes.fan",    "notes.file",    "notes.find",    "notes.format",    "notes.import",    "notes.info",    "notes.leave",    "notes.link",    "notes.links",    "notes.list",    "notes.memory",    "notes.merge_tags",    "notes.new",    "notes.open",    "notes.picture",    "notes.pin",    "notes.pin_tag",    "notes.remove",    "notes.restore",    "look",    "backup.screen",    "backup.turn",    "backup.code",    "backup.codePage",    "backup.codeSaved",    "backup.due",    "backup.make",    "backup.placed",    "backup.look",    "backup.restore",    "backup.reset",    "backup.undo",    "notes.settings",    "notes.side",    "notes.style",    "notes.tag",    "notes.tag_icon",    "notes.tag_icons",    "notes.tags",    "notes.themes",    "notes.unarchive",    "notes.unpin",    "notes.untag",    "notes.shared",    "pairing.approve",    "pairing.pending",    "share.by_person",    "share.do",    "share.plan",    "share.role",    "share.sheet",    "share.stop",    "share.with",    "circle.add.page",    "circle.answer",    "circle.ask",    "circle.ask.stop",    "circle.block",    "circle.invite",    "circle.invite.open",    "circle.invite.stop",    "circle.check",    "circle.check.confirm",    "circle.check.scan",    "circle.key.accept",    "circle.list",    "circle.remove",    "circle.remove.plan",    "circle.unblock",    "people.accept",    "people.add",    "people.block",    "people.fillCities",    "people.printsNeeded",    "people.refuse",    "people.pick",    "people.remove",    "people.unblock",    "people.unfillCities",    // THE LOCAL PHRASE PARSER, answered by `phone::phrase` through the same    // `parse_phrase` handler an MCP connection calls.    "phrase.parse",    "project.conversation",    "push.forget",    "read",    "records.addToCalendar",    "records.command",    "records.create",    "records.delete",    "records.get",    "records.head",    "records.link",    "records.list",    "records.move",    "settings.openFlow",    "message.import.choose",    "message.import.run",    "message.import.retry",    "message.import.owner",    "records.live",    "records.page",    "records.recordAsTransaction",    "records.reorder",    "records.resolve",    "records.search",    "records.spoken",    "records.summarize",    "records.undo",    "records.update",    "recovery.askHelp",    "recovery.check",    "recovery.circleAccept",    "recovery.circleApprove",    "recovery.circleAsks",    "recovery.circleDecline",    "recovery.circleHeld",    "recovery.circleSet",    "recovery.circleStart",    "recovery.circleStop",    "recovery.circleStopFor",    "recovery.circleWait",    "recovery.helpApprove",    "recovery.helpAsks",    "recovery.helpDecline",    "recovery.helped",    "recovery.make",    "recovery.makePlatform",    "recovery.open",    "recovery.openPlatform",    "recovery.screen",    "recovery.show",    "recovery.status",    "recovery.trust",    "reminders.desired",    "reminders.reconcile",    "routes.list",    // This Device's sample records: invented todos and events, made and binned.    "samples.add",    "samples.remove",    "seal.forgetKey",    "seal.heldKey",    "seal.makeKey",    "seal.mintKey",    "seal.openKey",    "seal.status",    "seal.useKey",    "assistant.allow",    "assistant.askEachTime",    "assistant.connect",    "assistant.key",    "assistant.keys",    "assistant.remove",    "assistant.scope",    "assistant.screen",    "assistant.stop",    "asks.allow",    "asks.card",    "asks.refuse",    "unlock.allow",    "unlock.allowAll",    "unlock.card",    "unlock.decline",    "unlock.end",    "unlock.reads",    "unlock.windows",    "session.create",    "session.resume",    "session.withdraw",    "settings.forgetVoiceTerm",    "settings.mediaBudget",    "settings.recordVoiceUse",    "settings.voiceTerm",    "ink.clear",    "ink.contest",    "ink.drop",    "ink.due",    "ink.edit",    "ink.knobs",    "ink.read",    "ink.stroke",    "shell.deck",    "shell.fan",    "shell.rail",    "shell.stream",    "shell.home",    "shell.account",    "shell.settings",    "shell.settings.now",    "shell.report",    "shell.freeUp",    "shell.today",    "shell.undo",    "shell.list",    "shell.plus",    "shell.draft",    "shell.input",    "shell.lines",    "contacts.export",    "contacts.import",    "count.words",    "cards.pages",    "storage.freeUp",    "storage.keepRule",    "storage.keptSpace",    "storage.measure",    "storage.setMacFiles",    "sync.background",    "sync.foreground",    "sync.now",    "sync.compact",    "sync.rejected",    "sync.retryRejected",    "sync.row",    "sync.stuck",    "sync.stuck.again",    "sync.stuck.letGo",    "sync.kept.seen",    "sync.status",    "terminal.attach",    "terminal.detach",    "terminal.resize",    "terminal.write",    "tools.act",    "tools.acts",    "tools.add",    "tools.export",    "tools.import",    "tools.list",    "tools.remove",    // The PASSWORDS (spec §6.2). A family of methods rather than tools    // because sealing is done HERE, under a key only this device's Keychain    // holds: `create_secret` runs with `ToolServices::none()` on a device and    // refuses by name, and the reveal is deliberately not a tool at all —    // there is no MCP verb that answers a value and there never will be.    // Cotton Keys' credential provider, drained by the app (`phone::passkeys`).    "passkey.create",    "passkey.identities",    "passkey.importCxf",    "passkey.mirror",    "passkey.register",    "passkey.sign",    "passkey.used",    // Cotton Keys' passwords, sealed and opened on this device (`phone::passwords`).    "password.add",    "password.change",    "password.generate",    "password.importCsv",    "password.list",    "password.mirror",    "password.new",    "password.remove",    "password.reveal",    "password.save",    "password.used",    // Cotton Contacts: home, person, add and edit, the address book, Same person?, merge (`phone::contacts_app`, `phone::contacts_same`).    "contacts.home",    "contacts.person",    "contacts.add.form",    "contacts.edit.form",    "contacts.add",    "contacts.edit",    "contacts.read",    "contacts.circle",    "contacts.same.list",    "contacts.same",    "contacts.same.pair",    "contacts.merge",    "contacts.unmerge",    "contacts.facts",    // Cotton Contacts: groups, archive and unarchive (`phone::contacts_groups`; assets/design/shared/CONTACTS-ANSWERS.md).    "contacts.archive",    "contacts.group",    "contacts.group.add",    "contacts.group.delete",    "contacts.group.make",    "contacts.group.remove",    "contacts.group.rename",    "contacts.groups",    "contacts.unarchive",    // Cotton Data, read only (`phone::data_app`; assets/design/data/CONTRACT.md).    "data.about",    "data.assistants",    "data.columns",    "data.dates",    "data.export",    "data.export.plan",    "data.keep",    "data.keep.set",    "data.keep.pause",    "data.keep.resume",    "data.keep.mobile_once",    "data.lately",    "data.leftovers",    "data.link",    "data.links",    "data.media",    "data.room",    "data.row",    "data.rows",    "data.search",    "data.stored",    "data.tables",    "data.welcome",    "data.you",    // Cotton Secrets' people and sharing (`phone::secrets_app`; CONTRACT.md).    "secrets.gate",    "secrets.needs",    "secrets.people",    "secrets.person",    "secrets.check",    "secrets.check.confirm",    "secrets.check.scan",    "secrets.share.plan",    "secrets.share",    "secrets.holders",    "secrets.held",    "secrets.take.plan",    "secrets.take",    "secrets.changed",    "secrets.reshare",    "secrets.inbox",    "secrets.shared",    "secrets.shared.field",    "secrets.shared.remove",    "secrets.shared.longer",    "secrets.ask",    "secrets.asks",    "secrets.ask.answer",    "secrets.ask.no",    "secrets.ask.withdraw",    "secrets.import.plan",    "secrets.import",    // Cotton Vault's screens (`phone::vault_app`; shapes in `cotton_core::keys::app::shapes`).    "vault.act",    "vault.code",    "vault.edit",    "vault.field",    "vault.generate",    "vault.history",    "vault.item",    "vault.items",    "vault.look",    "vault.save",    "vault.security",    "vault.settings",    "vault.approval",    "vault.approveDevice",    "vault.create",    "vault.keys",    // The Mac's one (spec §7.3): an import reads a file somebody picked in the    // Finder. `vault.place` and `vault.unplace` are every device's — the phone    // puts a secret on a Mac and the Mac it names applies it.    "vault.lock",    "vault.place",    "vault.publishKey",    "vault.refuseDevice",    "vault.restore",    "vault.reveal",    "vault.status",    "vault.trash",    "vault.unlock",    "vault.unplace",    "vault.update",    "voice.end",    "voice.heard",    "voice.model",    "voice.models",    "voice.plan",    "voice.settings",    "voice.touched",    "whatsapp.accounts",    "whatsapp.history",    "whatsapp.unlink",    "workspace.setCode",    "workspace.setReach",    "workspace.startLocal",    "write",];/// What EVERY build answers — the client half (H1).////// A phone answers all of these over its replica; a serving Mac answers the/// same names over the file its server holds open, and a client Mac over its/// replica like the phone. Nothing here embeds a server. The families, and why/// each is a method rather than a tool:////// * **`read`** stands for the whole `read.<name>` family (design P4): the///   names are [`crate::phone::reads::READS`]'s and are assembled by///   [`methods`] rather than written out a second time here, so a read added///   to that table appears in the method list with it. **`write`** is the one///   authoring method (P3)./// * **`join.*`, `bootstrap.*`, `migrate.*`** are a device's way in and its///   first copy of the file (P15, P16). **A MAC JOINS THE SAME WAY A PHONE///   DOES** (plan §A): it presents its key, somebody already in compares the///   six digits, and the file arrives. There is no second way in for a Mac and///   no role to choose first./// * **`sync.*`** — the loop's status and its one-shot pass, plus the two///   scene phases. A Mac has no home button; the phases are a no-op there.///   `sync.rejected` and `sync.retryRejected` are the writes a peer made that///   THIS file refused — kept whole since version 8 — and one more go at///   folding them. No screen yet; the names are how a person diagnosing a row///   that reached one device and not another gets an answer./// * **`export.build`** walks the whole database in one pass and answers a///   PATH, never the bytes./// * **`capture.create`, `capture.media`, `dictation.create`, `meetings.create`,///   `page.save`, `launch.*`, `settings.*`** are the writes the///   TOOL SURFACE DELIBERATELY HAS NO VERB FOR, each absence a written refusal —///   `create_meeting` does not exist because "meetings enter by recording or///   import on the phone";///   `create_thought` does not exist because a thought is something the///   person SAID; no tool writes///   a `_media` ledger row, because the ledger is device-local; no tool writes///   `cotton_dictations`; `create_page` is refused in so many words; and the///   four settings rows are `SUPPORTING_TABLES` the verb grid never owed an///   entry. See [`crate::authoring::author_through_outbox`]./// * **`media.ensure`** is the only read-shaped one, and it is here rather///   than in the `read.` family because it may FETCH./// * **`google.*`** and **`spotify.*`** ask the person's own object on the///   Worker, through the door `personal.connect` holds: the grant and the///   pull's state live there, not in the file./// * **`devices.*` and `push.forget`** ask the person's own///   server over the signed transport, and every one is a method rather than///   a read for the same reason: **the answer is not in the file**. On a///   serving Mac with no transport they refuse by name (`no_server`), which is///   truer than `unknown_method` — the capability exists, the address does///   not. Apple's push key is not configured here at all: the server reads///   it from the vault at each send./// * **`city.*`** reads the device-wide, read-only reference packages. No///   search term crosses a network or enters a personal database./// * **`people.fillCities`** — Cotton filling in the city of a person who///   has a zone and never had a city, run by the app rather than asked for by///   anyone, stamping each person with the pass; `people.unfillCities` takes///   one pass back from Home's Done for you./// * **`reminders.desired` / `reminders.reconcile`** — the local reminder///   pass, SHAPED like a read but answering a service rather than a screen./// * **`datadir.status`, `identity.get`, `log.lines`, `routes.list`** — where///   the file lives, who this device is, what was said before anyone listened,///   and the route table the Swift `Route` enum is held TOTAL against./// * **`build.facts`** — the store schema this build writes, the built-in///   definitions revision and the app version, for Cotton Dev's corner and About.pub const CLIENT_METHODS: &[&str] = &[    "story.places",    "story.place",    "story.person",    "story.pictures",    "story.things",    "story.costumes",    "story.fdx.write",    "story.drafts.list",    "story.drafts.read",    "story.drafts.changes",    "story.scene.split",    "story.scene.merge",    "story.merge",    "story.picture.add",    "story.picture.remove",    "story.picture.move",    "story.drafts.mark",    "story.drafts.restore",    "days.export",    "days.span",    "days.month",    "days.sometime",    "days.groups",    "days.item",    "days.change",    "days.done",    "days.undone",    "days.skip",    "days.move",    "days.read_line",    "days.add",    "days.marks",    "days.marks.find",    "days.google",    "days.google_disconnect",    "bootstrap.start",    "bootstrap.status",    "build.facts",    "camera.shot",    "calls.answer",    "calls.decline",    "calls.end",    "calls.history",    "calls.speaking",    "calls.mute",    "calls.leave",    "calls.invite",    "calls.join",    "calls.ack",    "calls.iceServers",    "calls.incoming",    "calls.link",    "calls.media",    "calls.openLink",    "calls.pushToken",    "calls.signal",    "calls.socketClosed",    "calls.start",    "calls.state",    "calls.stop",    "calls.tick",    "chat.accept",    "chat.ahead",    "chat.blocked",    "chat.sms.here",    "chat.sms.land",    "chat.sms.outbox",    "chat.sms.sent",    "chat.contact",    "chat.contacts",    "chat.invite",    "chat.profile",    "chat.profile.set",    "chat.profilePicture",    "chat.act",    "chat.block",    "chat.call",    "chat.callScreen",    "chat.calls",    "chat.recording",    "chat.recording.act",    "chat.recording.live",    "chat.compose",    "chat.downloads",    "chat.downloads.act",    "chat.downloads.send",    "chat.file",    "chat.flush",    "chat.ground",    "chat.forget",    "chat.incoming",    "chat.keep",    "chat.key",    "chat.export",    "chat.link",    "chat.list",    "chat.mail",    "chat.mail.act",    "chat.mail.compose",    "chat.mail.countSender",    "chat.mail.discard",    "chat.mail.file",    "chat.mail.free",    "chat.mail.page",    "chat.mail.hold",    "chat.mail.save",    "chat.mail.send",    "chat.mail.sender",    "chat.mail.thread",    "chat.mail.trashSender",    "chat.notices",    "chat.picture",    "chat.preview",    "chat.previews",    "chat.ratchet",    "chat.receipt",    "chat.refuse",    "chat.register",    "chat.retry",    "chat.rows",    "chat.safety",    "chat.safety.scan",    "chat.safety.verify",    "chat.search",    "chat.sender.act",    "chat.sender.ask",    "chat.sender.page",    "chat.senders",    "chat.senders.blocked",    "chat.send",    "chat.settings",    "chat.slips",    "chat.socket",    "chat.starred",    "chat.storage",    "chat.storage.free",    "chat.start",    "chat.text",    "chat.theme",    "chat.theme.set",    "chat.themes",    "chat.thread",    "chat.timer.binned",    "chat.timer.erase",    "chat.timer.restore",    "chat.typing",    "chat.unblock",    "chat.warm",    "chat.waveform",    "chat.waveforms",    "chat.you",    "chat.you.now",    "mail.home",    "mail.list",    "mail.side",    "mail.thread",    "mail.page",    "mail.file",    "mail.free",    "mail.files",    "mail.search",    "mail.archive",    "mail.act",    "mail.undo",    "mail.after",    "mail.ask",    "mail.do",    "mail.bin.empty",    "mail.you",    "mail.set",    "mail.pictures.always",    "mail.link",    "mail.hold",    "mail.rules",    "mail.verdict",    "mail.senders",    "mail.sender",    "mail.sender.merge",    "mail.sender.part",    "mail.sender.name",    "mail.blocked",    "mail.unblock",    "mail.compose",    "mail.save",    "mail.discard",    "mail.attach",    "mail.unattach",    "mail.send",    "mail.unsend",    "mail.sending",    "mail.accounts",    "mail.account.plan",    "mail.account.add",    "mail.account",    "mail.account.way",    "mail.account.set",    "mail.account.forget",    "mail.account.remove",    "mail.fetch",    "mail.domains",    "mail.domain",    "mail.domain.add",    "mail.domain.remove",    "mail.domain.check",    "mail.domain.catch_all",    "mail.address.add",    "mail.address.remove",    "sites.add",    "sites.book.leave",    "sites.add.plan",    "sites.delete",    "sites.edit",    "sites.left",    "sites.link",    "sites.list",    "sites.open",    "sites.arrange",    "sites.block",    "sites.choose",    "sites.close",    "sites.exit",    "sites.failed",    "sites.fill",    "sites.forget",    "sites.home",    "sites.live",    "sites.login",    "sites.logins",    "sites.move.done",    "sites.move.in",    "sites.move.out",    "sites.panel",    "sites.save_to_words",    "sites.search",    "sites.set",    "sites.settings",    "sites.state",    "sites.storage",    "sites.trackers",    "sites.wait",    "sites.keep_one",    "sites.orphans.remove",    "sites.stores.gone",    "sites.stores.keep",    "sites.stores.removed",    "sites.undo",    "send.decline",    "send.inbox",    "send.keep",    "send.make",    "send.offer",    "send.picture",    "send.trust",    "send.undo",    "shared.add",    "shared.found",    "shared.lists",    "shared.put",    "shared.read",    "shared.remove",    "shared.take",    "capture.avatar",    "capture.media",    "shell.opened",    "cards.birthdays",    "cards.factLabels",    "cards.moneyDue",    "cards.repeat",    "cards.when",    "code.preferences.import",    "code.preferences.read",    "code.preferences.set",    "business.sync",    "business.pages",    "business.code",    "business.signIn",    "business.signOut",    "business.act",    "personal.ask",    "personal.askPoll",    "personal.handoff",    "personal.passkeyBegin",    "personal.passkeySignIn",    "personal.code",    "personal.signIn",    "personal.connect",    "personal.adopt",    "personal.adoptStatus",    "personal.standLocal",    "personal.remove",    "account.delete",    "account.deleteCode",    "account.deletePage",    "account.forget",    "account.keep",    "account.leave",    "restore.points",    "restore.begin",    "restore.progress",    "restore.cancel",    "restore.after",    // WHICH DATABASE A WINDOW IS DRAWING (`phone/databases.rs`): a counted pin    // per window, so a pass over the idle files never closes one on screen.    // Made on this device with no network (`phone/databases.rs`); on the Mac    // that holds the household's databases, the server's own maker.    "databases.create",    "databases.delete",    "databases.restore",    "databases.hide",    "databases.invite",    "databases.leave",    "databases.present",    "databases.remove",    "databases.show",    "databases.toolkits",    "datadir.status",    // THE TABLE AND TOOL DEFINITIONS, and the generic verbs below, answered by    // `phone::records` through the same handlers an MCP connection calls.    "definitions.board",    "definitions.catalogue",    "definitions.contributors",    "definitions.passedOver",    "definitions.resetBoard",    "definitions.saveBoard",    "definitions.saveTable",    "definitions.saveTheme",    "definitions.tables",    "definitions.theme",    "definitions.undoTheme",    "definitions.tools",    // Cotton Dev only: this phone's copy stamped as the build before this    // one wrote it — the release walk's schema bump under unsent changes.    "developer.stampStaleCopy",    // Cotton Dev only: a theme row as a newer build would sync it in.    "developer.wearThemeRow",    // Cotton Dev only: invented writing an assistant made (notes, web pages,    // memory), for a look at Words' Your assistant on a simulator.    "developer.inventAssistantWriting",    "developer.inventNoteFiles",    "developer.inventServedCopy",    "developer.cutNetwork",    // Cotton Dev only: kept chat pictures left plain as an app before 22 Nov 2026 kept them, and the check after the reseal.    "developer.inventKeptPictures",    "developer.checkKeptPictures",    "developer.resealKept",    // Cotton Dev only: invented mail for Comms (MAIL.md), on an emulator or an invented account as large as the owner's.    "developer.inventMail",    // Cotton Dev only: a delete for everyone the Mac's link would report, for a walk with no Mac (FEEDBACK-3).    "developer.revokeWhatsapp",    "developer.fakeMac",    // Cotton Dev only: WhatsApp chats whose people carry profile pictures, and a poll, as the Mac's link lands them.    "developer.inventWhatsappFaces",    // Cotton Dev only: invented senders across WhatsApp and SMS, for a walk of People (SENDERS.md).    "developer.inventSenders",    // Cotton Dev only: the iPhone's walk of People: senders on WhatsApp, by SMS and by mail, in one write.    "developer.inventPeopleWalk",    // Cotton Dev only: Look's table as a server before Look serves it (no type_face), for a face chosen there.    "developer.lookServedBefore",    // Cotton Dev only: two changes that cannot be sent, for a walk of the Sync page's Send again and Let go (UNSENT HEAL).    "developer.stuckChange",    "device.becomeRunner",    "device.facts",    "device.notifications.asked",    "device.notifications.openSettings",    "device.notifications.request",    "device.preferences.import",    "device.preferences.read",    "device.preferences.set",    "device.rekey",    "device.rekey.cancel",    "device.rekey.start",    "device.rekey.status",    // The serving Mac's sender, from its own row: its line and Test push —    // run in-process on that Mac, signed to it from anywhere else.    "device.push",    "device.serveFrom",    "device.setSessions",    "device.setAiCap",    "device.testPush",    "device.pushAck",    "devices.approvePending",    "devices.declinePending",    "devices.list",    "devices.pending",    "devices.rename",    "devices.revoke",    "diagnostics.debug",    "diagnostics.removeCopy",    "diagnostics.report",    "diagnostics.say",    "dictation.create",    // THE OWNER'S ACTS ON A DOMAIN (`phone::domains`): a signed call to the    // serving Mac, which holds the Cloudflare token; run only as the Domains    // page's commands.    "domains.checkPrice",    "domains.handOver",    "domains.register",    "export.build",    "package.export",    "package.exportOpen",    "package.import",    "feedback.flush",    "feedback.send",    "usage.record",    // A film's stream address and what this device keeps of each film    // (`phone::films`): the object signs the one, the other never syncs.    "films.here.read",    "films.here.write",    // An admitted act at the person's object (`phone::object_acts`).    "object.act",    // What this device keeps of each book's file, its Remove download and    // Add a folder (`phone::books`); the reader opening one (`phone::reader`).    "books.here.due",    "books.here.read",    "books.here.write",    "books.remove",    "books.folder",    "reader.open",    "shell.reader",    "shell.reading",    "reader.moved",    "reader.highlight",    "reader.settings",    "reader.seek",    "reader.seek.say",    "reader.seek.go",    "reader.seek.back",    // Cotton Music (`phone::songs`): the intake, what this device keeps of    // each song's file, the one player (`phone::shell_player`: songs, podcast    // episodes and films) and an album's lookups.    "music.capture",    "music.zip",    "music.lists",    "songs.here.read",    "songs.here.write",    "songs.remove",    "songs.keepEverything",    "songs.keepPlan",    "shell.player",    "music.findDetails",    "music.fill",    // Android's song intake (`phone::song_intake`): which picked files are    // songs, the writes they gather into, what the intake came to.    "music.picked",    "music.gathered",    "music.landed",    // Cotton Cinemas (`phone::film_intake`, `phone::film_player`): the    // intake, Keep everything and a whole file's Remove download, and Mark    // watched. A film plays through `shell.player`.    // Cotton Money (`phone::money`): how its objects print an amount, Pay by    // UPI's deep link, and a statement brought in at Plus.    "money.print",    "money.upiPay",    "money.statements.capture",    "films.capture",    "films.picked",    // Give subtitles (`phone::film_subtitle_file`): a .srt or .vtt picked from the phone's files, kept sealed for the Mac.    "films.subtitleFile",    "films.keepEverything",    "films.remove",    "films.keeping",    "films.onPhone",    "cinemas.home",    "cinemas.row",    "cinemas.season",    "cinemas.search",    "cinemas.kind",    "cinemas.groups",    "cinemas.hide",    "cinemas.hidden",    "cinemas.unlock",    "cinemas.lock",    "cinemas.groupsOrder",    "groups.order",    "cinemas.title",    "cinemas.toEpisode",    "cinemas.subtitles",    "cinemas.onPhone",    "cinemas.preparing",    "cinemas.remote",    "cinemas.shared",    "cinemas.shared.leave",    "cinemas.bin",    "cinemas.restore",    "cinemas.erase",    "cinemas.you",    "cinemas.setting",    "films.keepPlan",    "films.mark",    // Cotton Health (`phone::health`): what HealthKit is asked for, the    // anchors kept per type, a batch landed, the export read, the summaries.    "health.anchor",    "health.held",    "health.land",    "health.readExport",    "health.summary",    "health.types",    // Cotton Health's screens (`phone::health_app`; shapes in `cotton_core::health::app::shapes`).    "health.act",    "health.addPerson",    "health.addReport",    "health.body",    "health.labs",    "health.look",    "health.metric",    "health.parameter",    "health.people",    "health.report",    "health.reports",    "health.settings",    // Cotton Story (`phone::story`): the writer's lines, Return and Tab, the    // element bar and names; a scene's writes and order; the current story;    // cards, the laid-out script and Fountain out and in (apps/story/CORE.md).    "story.answer",    "story.character.add",    "story.draft",    "story.interval",    "story.interview",    "story.line.add",    "story.line.edit",    "story.line.remove",    "story.line.move",    "story.person.lines",    "story.list",    "story.scene",    "story.scene.add",    "story.scene.place",    "story.scene.leave",    "story.scene.remove",    "story.scenes",    "story.sequence.add",    "story.sequence.edit",    "story.sequence.remove",    "story.skip",    "story.theme.set",    "story.themes",    "story.card",    "story.chat",    "story.choose",    "story.copy",    "story.current",    "story.figures",    "story.fountain.read",    "story.bring_in",    "story.fountain.write",    "story.kind",    "story.lines",    "story.names",    "story.press",    "story.rename",    "story.scene.duplicate",    "story.scene.move",    "story.scene.near",    "story.scene.new",    "story.scene.write",    "story.script",    "story.start",    "story.write",    "google.connect",    "google.disconnect",    "google.status",    "signin.approve",    "signin.approveSibling",    "signin.asks",    "signin.passkeyAdd",    "signin.passkeyOptions",    "signin.passkeyRemove",    "signin.passkeys",    "signin.refuse",    "signin.show",    "signin.siblingTicket",    "gettingIn.again",    "gettingIn.screen",    "spotify.connect",    "spotify.disconnect",    "spotify.status",    "groups.create",    "groups.delete",    "groups.list",    "groups.update",    "identity.get",    "import.whatsappExport",    "keep.audience",    "keep.clear",    "keep.open",    "keep.reconcile",    "keep.rules",    "keep.set",    "log.lines",    "media.ensure",    "media.network",    "media.stream",    "media.uploads",    "media.viewed",    "meetings.action.todo",    "meetings.delete",    "meetings.export",    "meetings.import",    "meetings.language",    "meetings.line.correct",    "meetings.merge",    "meetings.next",    "meetings.note",    "meetings.read",    "meetings.record.discard",    "meetings.record.recover",    "meetings.record.start",    "meetings.record.stop",    "meetings.record.tick",    "meetings.search",    "meetings.speaker.name",    "meetings.summarise",    "meetings.title",    "meetings.transcribe",    "meetings.transcribed",    "meetings.windows",    "media.describe",    "media.share",    "members.admit",    "members.claimPerson",    "migrate.status",    "page.save",    "share.fetchLinks",    "share.door",    "link.open",    // Cotton Notes (`phone::notes`): the list, the fan, the writer's text,    // spans and buttons, tags as groups, archive and bin, look and type, and    // Bring notes in (cotton_rules::writing).    "notes.archive",    "notes.bin",    "notes.edit",    "notes.empty_bin",    "notes.export",    "notes.fan",    "notes.file",    "notes.find",    "notes.format",    "notes.import",    "notes.info",    "notes.leave",    "notes.link",    "notes.links",    "notes.list",    "notes.memory",    "notes.merge_tags",    "notes.new",    "notes.open",    "notes.picture",    "notes.pin",    "notes.pin_tag",    "notes.remove",    "notes.restore",    "look",    "backup.screen",    "backup.turn",    "backup.code",    "backup.codePage",    "backup.codeSaved",    "backup.due",    "backup.make",    "backup.placed",    "backup.look",    "backup.restore",    "backup.reset",    "backup.undo",    "notes.settings",    "notes.side",    "notes.style",    "notes.tag",    "notes.tag_icon",    "notes.tag_icons",    "notes.tags",    "notes.themes",    "notes.unarchive",    "notes.unpin",    "notes.untag",    "notes.shared",    "pairing.approve",    "pairing.pending",    "share.by_person",    "share.do",    "share.plan",    "share.role",    "share.sheet",    "share.stop",    "share.with",    "circle.add.page",    "circle.answer",    "circle.ask",    "circle.ask.stop",    "circle.block",    "circle.invite",    "circle.invite.open",    "circle.invite.stop",    "circle.check",    "circle.check.confirm",    "circle.check.scan",    "circle.key.accept",    "circle.list",    "circle.remove",    "circle.remove.plan",    "circle.unblock",    "people.accept",    "people.add",    "people.block",    "people.fillCities",    "people.printsNeeded",    "people.refuse",    "people.pick",    "people.remove",    "people.unblock",    "people.unfillCities",    // THE LOCAL PHRASE PARSER, answered by `phone::phrase` through the same    // `parse_phrase` handler an MCP connection calls.    "phrase.parse",    "project.conversation",    "push.forget",    "read",    "records.addToCalendar",    "records.command",    "records.create",    "records.delete",    "records.get",    "records.head",    "records.link",    "records.list",    "records.move",    "settings.openFlow",    "message.import.choose",    "message.import.run",    "message.import.retry",    "message.import.owner",    "records.live",    "records.page",    "records.recordAsTransaction",    "records.reorder",    "records.resolve",    "records.search",    "records.spoken",    "records.summarize",    "records.undo",    "records.update",    "recovery.askHelp",    "recovery.check",    "recovery.circleAccept",    "recovery.circleApprove",    "recovery.circleAsks",    "recovery.circleDecline",    "recovery.circleHeld",    "recovery.circleSet",    "recovery.circleStart",    "recovery.circleStop",    "recovery.circleStopFor",    "recovery.circleWait",    "recovery.helpApprove",    "recovery.helpAsks",    "recovery.helpDecline",    "recovery.helped",    "recovery.make",    "recovery.makePlatform",    "recovery.open",    "recovery.openPlatform",    "recovery.screen",    "recovery.show",    "recovery.status",    "recovery.trust",    "reminders.desired",    "reminders.reconcile",    "samples.add",    "samples.remove",    "seal.forgetKey",    "seal.heldKey",    "seal.makeKey",    "seal.mintKey",    "seal.openKey",    "seal.status",    "seal.useKey",    "assistant.allow",    "assistant.askEachTime",    "assistant.connect",    "assistant.key",    "assistant.keys",    "assistant.remove",    "assistant.scope",    "assistant.screen",    "assistant.stop",    "asks.allow",    "asks.card",    "asks.refuse",    "unlock.allow",    "unlock.allowAll",    "unlock.card",    "unlock.decline",    "unlock.end",    "unlock.reads",    "unlock.windows",    "routes.list",    "session.create",    "session.resume",    "session.withdraw",    "settings.forgetVoiceTerm",    "settings.mediaBudget",    "settings.recordVoiceUse",    "settings.voiceTerm",    "ink.clear",    "ink.contest",    "ink.drop",    "ink.due",    "ink.edit",    "ink.knobs",    "ink.read",    "ink.stroke",    "shell.deck",    "shell.fan",    "shell.rail",    "shell.stream",    "shell.home",    "shell.account",    "shell.settings",    "shell.settings.now",    "shell.report",    "shell.freeUp",    "shell.today",    "shell.undo",    "shell.list",    "shell.plus",    "shell.draft",    "shell.input",    "shell.lines",    "contacts.export",    "contacts.import",    "count.words",    "cards.pages",    "storage.freeUp",    "storage.keepRule",    "storage.keptSpace",    "storage.measure",    "storage.setMacFiles",    "sync.background",    "sync.foreground",    "sync.now",    "sync.compact",    "sync.rejected",    "sync.retryRejected",    "sync.row",    "sync.stuck",    "sync.stuck.again",    "sync.stuck.letGo",    "sync.kept.seen",    "sync.status",    // The PASSWORDS (spec §6.2). A family of methods rather than tools    // because sealing is done HERE, under a key only this device's Keychain    // holds: `create_secret` runs with `ToolServices::none()` on a device and    // refuses by name, and the reveal is deliberately not a tool at all —    // there is no MCP verb that answers a value and there never will be.    "terminal.attach",    "terminal.detach",    "terminal.resize",    "terminal.write",    "tools.act",    "tools.acts",    "tools.add",    "tools.export",    "tools.import",    "tools.list",    "tools.remove",    // Cotton Keys' credential provider, drained by the app (`phone::passkeys`).    "passkey.create",    "passkey.identities",    "passkey.importCxf",    "passkey.mirror",    "passkey.register",    "passkey.sign",    "passkey.used",    // Cotton Keys' passwords, sealed and opened on this device (`phone::passwords`).    "password.add",    "password.change",    "password.generate",    "password.importCsv",    "password.list",    "password.mirror",    "password.new",    "password.remove",    "password.reveal",    "password.save",    "password.used",    // Cotton Contacts: home, person, add and edit, the address book, Same person?, merge (`phone::contacts_app`, `phone::contacts_same`).    "contacts.home",    "contacts.person",    "contacts.add.form",    "contacts.edit.form",    "contacts.add",    "contacts.edit",    "contacts.read",    "contacts.circle",    "contacts.same.list",    "contacts.same",    "contacts.same.pair",    "contacts.merge",    "contacts.unmerge",    "contacts.facts",    // Cotton Contacts: groups, archive and unarchive (`phone::contacts_groups`; assets/design/shared/CONTACTS-ANSWERS.md).    "contacts.archive",    "contacts.group",    "contacts.group.add",    "contacts.group.delete",    "contacts.group.make",    "contacts.group.remove",    "contacts.group.rename",    "contacts.groups",    "contacts.unarchive",    // Cotton Data, read only (`phone::data_app`; assets/design/data/CONTRACT.md).    "data.about",    "data.assistants",    "data.columns",    "data.dates",    "data.export",    "data.export.plan",    "data.keep",    "data.keep.set",    "data.keep.pause",    "data.keep.resume",    "data.keep.mobile_once",    "data.lately",    "data.leftovers",    "data.link",    "data.links",    "data.media",    "data.room",    "data.row",    "data.rows",    "data.search",    "data.stored",    "data.tables",    "data.welcome",    "data.you",    // Cotton Secrets' people and sharing (`phone::secrets_app`; CONTRACT.md).    "secrets.gate",    "secrets.needs",    "secrets.people",    "secrets.person",    "secrets.check",    "secrets.check.confirm",    "secrets.check.scan",    "secrets.share.plan",    "secrets.share",    "secrets.holders",    "secrets.held",    "secrets.take.plan",    "secrets.take",    "secrets.changed",    "secrets.reshare",    "secrets.inbox",    "secrets.shared",    "secrets.shared.field",    "secrets.shared.remove",    "secrets.shared.longer",    "secrets.ask",    "secrets.asks",    "secrets.ask.answer",    "secrets.ask.no",    "secrets.ask.withdraw",    "secrets.import.plan",    "secrets.import",    // Cotton Vault's screens (`phone::vault_app`; shapes in `cotton_core::keys::app::shapes`).    "vault.act",    "vault.code",    "vault.edit",    "vault.field",    "vault.generate",    "vault.history",    "vault.item",    "vault.items",    "vault.look",    "vault.save",    "vault.security",    "vault.settings",    "vault.approval",    "vault.approveDevice",    "vault.create",    "vault.keys",    "vault.lock",    "vault.place",    "vault.publishKey",    "vault.refuseDevice",    "vault.restore",    "vault.reveal",    "vault.status",    "vault.trash",    "vault.unlock",    "vault.unplace",    "vault.update",    "voice.end",    "voice.heard",    "voice.model",    "voice.models",    "voice.plan",    "voice.settings",    "voice.touched",    "whatsapp.accounts",    "whatsapp.history",    "whatsapp.unlink",    "workspace.setCode",    "workspace.setReach",    "workspace.startLocal",    "write",];/// Every method name THIS build answers, sorted.////// The `read.` family is expanded here, so an app asking for a method that does/// not exist is told the real list rather than a placeholder.pub fn methods() -> Vec<String> {    let mut names: Vec<String> = crate::phone::method_names();    names.sort();    names}/// The methods that belong to the PERSON rather than to a database (Spec 9.5):/// Voice words and diagnostics use the/// personal database whichever `database` the call names, the way `read.you`/// and `read.voiceVocabulary` already did for themselves. A shared database/// named beside one of these is dropped, not refused: the app opens these/// lists from any database, and they are the same list in every one. Generic/// feedback record reads keep their explicit database scope.pub const PERSON_METHODS: [&str; 9] = [    "definitions.passedOver",    "diagnostics.debug",    "diagnostics.removeCopy",    "diagnostics.report",    "usage.record",    "read.recentVisits",    "read.voiceVocabulary",    "settings.forgetVoiceTerm",    "settings.voiceTerm",];/// What an app scoped to one database may call before that database has/// arrived (`shell::scope`): the fill and the sync that bring it, the/// device's own state, and the list of databases — none of them answers a/// record. Everything else waits for the database.pub const ARRIVAL_METHODS: [&str; 15] = [    "bootstrap.",    "sync.",    "migrate.",    "pairing.",    "device.",    "devices.",    "push.",    "diagnostics.",    "log.",    "usage.",    "read.databases",    // The boot's own two reads: the join cache and the sync's state. Refused,    // the app stopped on its error card and never started the sync that    // brings the database (walk).    "read.boot",    "read.syncStatus",    // The gate itself: it reads the boot's facts and opens the copy.    "shell.home",    // The app's own words: a refusal and a join are drawn before any    // database has arrived, in the kit's words.    "shell.lines",];fn arrival_method(method: &str) -> bool {    ARRIVAL_METHODS.iter().any(|allowed| {        if allowed.ends_with('.') {            method.starts_with(allowed)        } else {            method == *allowed        }    })}/// Dispatch one call. `request` is whatever JSON the app sent (an absent body/// reads as `{}`).////// **THE DATABASE IS NAMED HERE, once, for every method.** A top-level/// `database` beside the method's own arguments is the id of the held database/// the call is about; ABSENT is the device's own (personal) one. It is taken/// out before the method sees its request, so no read or tool is handed an/// argument it never declared. `"all"` is the three feeds' word/// (`phone/databases.rs`) and no other method's./// Customer calls instead keep `database`: it names the remote business,/// alongside its `server`, whether or not this device holds a database.pub fn dispatch(    handle: &CottonHandle,    method: &str,    request: &Value,) -> Result<Value, MethodError> {    // A person's call on a Mac takes back an index being made (INDEX LATER 2).    crate::phone::mail_index::called(method);    // A refusal left on this thread by an earlier call is not this call's.    let _ = cotton_client::replica::take_read_refusal();    let _ = cotton_tools::mcp::handlers::tables::take_being_worked_out();    let answer = retry_interrupted_read(method, || dispatch_on(handle, method, request))        .map_err(|error| moving(handle, method, request, error))        .map_err(|error| could_not_read(method, error));    // FIRST SYNC STATES: a home, list or count answer of a copy in its first sync says its things are coming.    let answer = crate::phone::first_sync::on_answer(&handle.client(), method, answer)?;    // Find's hits and sections are worded once the read (one database or    // all) is whole (`phone::find_words`).    if method == "read.find" {        // HIDE FROM SCREEN: Find never names a title hidden in Cinemas, nor counts it; its read leaves them out where        // the rows are read (`phone::reads::find`, CORE 4), so nothing is dropped from its answer here.        return crate::phone::find_words::word(handle, request, answer);    }    Ok(answer)}/// A call from the app (`ffi::cotton_call`): [`dispatch`], once any swap of/// the database this phone stands on is over (`shell::swap`: Sign out, a/// sign-in over a copy that goes aside or comes back, a deleted account/// forgotten). Android asks on four threads, and a read landing between a/// sign-out's detach and its fresh database answered "has not started or/// joined a database yet" (Words' launch walk, 22 Nov 2026). A call a swap/// overtook part way and that failed is asked again once it is over, when it/// only reads or met no database (so wrote nothing): its answer is the/// database's that stands after the swap. The wait is before the call, never/// under any lock it takes.pub fn dispatch_across_swaps(handle: &CottonHandle, method: &str, request: &Value) -> Result<Value, MethodError> {    // Asked for every request a page makes, and it reads nothing of any database: never behind a swap.    if method == "sites.block" {        return Ok(crate::phone::sites::app::block(request));    }    let client = handle.client();    let gate = client.swap_gate();    let epoch = gate.epoch();    gate.wait_out();    match dispatch(handle, method, request) {        Err(error)            if gate.epoch() != epoch                && !method.starts_with("personal.")                && !method.starts_with("account.")                && (read_only(method) || error.message.contains(&crate::shell::client::not_connected_sentence())) =>        {            gate.wait_out();            dispatch(handle, method, request)        }        answered => answered,    }}/// `details.why` of a read that met a table mid-move.pub const MOVING: &str = "moving";/// A READ that met a table whose background move is not done — the computed/// index the open left stale, rebuilt after it on `cotton-index` — answers/// the typed could-not-read line `moving`, with the `table` it asked and the/// `database` it read, never the engine's sentence and never `unreadable`/// (which offers Try again): the app draws the database definition's/// `words.could_not_read.moving` and reads again on the move's done signal/// (`shell::client::MOVES_DONE_ORIGIN`; passivemove rule 3). No schema/// version rides it. A write keeps its own refusal.////// A read that fails on a database whose SCHEMA move is under way — a copy/// another build stamped, its tables moving after the open one per/// transaction (passivemove rule 1) — answers the same line: a table not yet/// moved is in its old shape, and what failed is the move not being done.fn moving(handle: &CottonHandle, method: &str, request: &Value, error: MethodError) -> MethodError {    if error.code == COULD_NOT_READ || !read_only(method) {        return error;    }    let database = request        .get("database")        .and_then(Value::as_str)        .filter(|named| *named != "all")        .map(str::to_string)        .or_else(|| handle.client().attached_database());    let mid_move = database        .as_deref()        .and_then(cotton_client::moves::left)        .is_some();    if !mid_move && !cotton_tools::mcp::handlers::tables::take_being_worked_out() {        return error;    }    MethodError::new(COULD_NOT_READ, error.message).with_details(json!({        "why": MOVING,        "method": method,        "table": request.get("table").and_then(Value::as_str),        "database": database,    }))}/// Retry a read on a fresh snapshot once if SQLite interrupted it. Mutating/// methods never replay: their first attempt may already have committed.fn retry_interrupted_read<T>(    method: &str,    mut read: impl FnMut() -> Result<T, MethodError>,) -> Result<T, MethodError> {    let first = read();    if read_only(method)        && first            .as_ref()            .is_err_and(|error| error.message.contains("sqlite: interrupted"))    {        let _ = cotton_client::replica::take_read_refusal();        read()    } else {        first    }}/// Whether `method` only reads: a `read.` method, a `records.*` verb whose/// tool is a read, or one of the page and definition reads. The ONE test the/// interrupted-read retry and the `mac_away` line both ask, so a read that/// retries is a read that is said away, and a write is neither.pub(crate) fn read_only(method: &str) -> bool {    method.starts_with("read.")        || crate::phone::records::tool_for(method)            .and_then(cotton_tools::mcp::protocol::tool_by_name)            .is_some_and(|entry| entry.scope == cotton_tools::mcp::protocol::McpScope::Read)        || matches!(            method,            "records.page"                | "shell.deck"                | "shell.list"                | "shell.plus"                | "shell.fan"                | "shell.stream"                | "shell.account"                | "shell.settings"                | "shell.settings.now"                | "shell.report"                | "shell.today"                | "tools.acts"                | "shell.opened"                | "shell.reader"                | "shell.reading"                | "cards.birthdays"                | "cards.factLabels"                | "cards.moneyDue"                | "records.live"                | "records.head"                | "records.resolve"                | "definitions.catalogue"                | "definitions.board"                | "definitions.theme"                | "definitions.tables"                | "definitions.tools"                | "definitions.contributors"        )}/// A method refused because the read pool refused its read answers the/// TYPED could-not-read line, never the composed sentence under it: the code/// `could_not_read` and `details.why` — `busy` (every connection of its lane/// was held past the wait) or `too_long` (it ran past the short lane's/// deadline) — which the app draws from its definition. Neither is a file/// that cannot be read, so nothing offers to remove the copy over one; the/// sentence stays as the message, for the log (readpool, 16 Oct 2026).pub const COULD_NOT_READ: &str = "could_not_read";pub(crate) fn could_not_read(method: &str, error: MethodError) -> MethodError {    let refusal = cotton_client::replica::take_read_refusal();    // A read already typed (a metering read's `on_the_mac`) keeps its why: a    // refusal left by a read it made on the way is not what it answered.    if error.code == COULD_NOT_READ {        return error;    }    let Some(refused) = refusal else {        return mac_away(method, error);    };    let why = match refused {        cotton_client::replica::ReadRefused::Busy => "busy",        cotton_client::replica::ReadRefused::TooLong => "too_long",    };    MethodError::new(COULD_NOT_READ, error.message)        .with_details(json!({ "why": why, "method": method }))}/// A READ whose transport never reached the serving Mac — no answer at all/// (status 0) or a gateway's (502–504) — answers the typed could-not-read/// line `mac_away`, never the transport's text: that names the relay's/// address and the resolver's words ("https://… could not be resolved"),/// and it reached Devices and AI usage offline (293 walk rows 159 and 169;/// architect's offline-truth ruling, 17 Oct 2026). The text stays as the/// message, for the log. It is EVERY read-only method ([`read_only`]) — a/// record's page, the live list, a definition, the Everything counts — not/// the `read.` family and the two list verbs alone (294 walk row G). A write/// keeps its own refusal.fn mac_away(method: &str, error: MethodError) -> MethodError {    let read = read_only(method);    let unreached = error        .details        .get("status")        .and_then(Value::as_u64)        .is_some_and(|status| matches!(status, 0 | 502..=504));    if !read || !unreached || error.code == COULD_NOT_READ {        return error;    }    MethodError::new(COULD_NOT_READ, error.message)        .with_details(json!({ "why": "mac_away", "method": method }))}/// Methods whose meaning requires the device's own Personal, even while another file is shown.fn personal_method(method: &str, request: &Value) -> bool {    matches!(        method,        "read.you"            | "read.voiceVocabulary"            | "read.recentVisits"            | "read.keyboardSnapshot"            | "usage.record"            | "diagnostics.report"            | "settings.forgetVoiceTerm"            | "settings.voiceTerm"            | "settings.recordVoiceUse"    ) || method.starts_with("import.")        || method.starts_with("message.import.")        || method.starts_with("mail.")        || method.starts_with("email.")        || (method.starts_with("records.")            && matches!(                request["table"].as_str(),                Some(                    "email"                        | "email_thread"                        | "email_sender"                        | "message_import"                        | "person_suggestion"                        | "mood"                )            ))        || (method == "capture.media" && request["into"] == "thought")}fn dispatch_on(handle: &CottonHandle, method: &str, request: &Value) -> Result<Value, MethodError> {    use crate::phone::databases::{ALL_DATABASES, DATABASE};    // The business methods speak to the flavour's business object, not the    // phone's held files: they bypass both the shown-database policy and the    // held-database argument stripping.    if crate::phone::business::METHODS.contains(&method) || crate::phone::personal_object::METHODS.contains(&method) || crate::phone::signin_approval::ASKING_METHODS.contains(&method) || crate::phone::account_passkey::ASKING_METHODS.contains(&method) || crate::phone::account_delete::METHODS.contains(&method) || crate::phone::restore::METHODS.contains(&method) {        return answer(handle, method, request);    }    // Personal arrivals never fall back to a joined business file.    if personal_method(method, request) {        handle.client().require_personal().map_err(|reason| {            MethodError::new(                cotton_core::genesis::NO_PERSONAL_DATABASE_IN_FLAVOUR,                reason,            )        })?;    }    let not_held = |reason: String| MethodError::new("database_not_held", reason);    let named = match request.get(DATABASE) {        None | Some(Value::Null) => None,        Some(Value::String(id)) if !id.trim().is_empty() => Some(id.as_str()),        Some(other) => {            return Err(MethodError::new(                "bad_request",                format!("`database` is the id of a database this device holds, not {other}"),            ))        }    };    // WHICH DATABASE THIS APP SHOWS (`shell::scope`, owner 19 Oct 2026: one    // app, one database). An app whose manifest names one makes and joins no    // other; a call naming a held database the app does not show is refused;    // the feeds' "all" is the shown database alone; and a call naming none is    // the shown database's (below) — Personal stays held for the person's own    // facts and is never what a screen reads.    let no_personal = handle.client().genesis() == cotton_core::genesis::Genesis::None;    if no_personal {        if let Some(id) = named {            if handle                .client()                .databases()                .map_err(not_held)?                .iter()                .any(|database| database.id == id && database.personal)            {                return Err(MethodError::new(                    cotton_core::genesis::NO_PERSONAL_DATABASE_IN_FLAVOUR,                    cotton_core::genesis::NO_PERSONAL_MESSAGE,                ));            }        }    }    let scope = handle.client().scope().clone();    let mut shown_only: Option<String> = match scope {        crate::shell::scope::DatabaseScope::Every => None,        _ => {            if matches!(method, "databases.create" | "databases.present") {                return Err(MethodError::new(                    "not_shown",                    "This app holds one database.",                ));            }            // A device that has joined nothing holds no database at all — not            // even Personal — and its calls answer as they always have, so            // Start and Join can draw (walk: refusing them            // left Cotton Development unable to pair).            if handle.client().databases().map_err(not_held)?.is_empty() {                return page_acts::run(handle, method, request, |method, request| {                    answer(handle, method, request)                });            }            let shown = handle.client().scoped_databases().map_err(not_held)?;            if let Some(id) = named.filter(|id| *id != ALL_DATABASES) {                if !shown.iter().any(|database| database.id == id) {                    return Err(MethodError::new(                        "not_shown",                        crate::shell::scope::NOT_SHOWN,                    ));                }            }            shown.into_iter().next().map(|database| database.id)        }    };    if no_personal && shown_only.is_none() {        shown_only = handle            .client()            .scoped_databases()            .map_err(not_held)?            .into_iter()            .next()            .map(|database| database.id);    }    let named = match (named, shown_only.as_deref(), &scope) {        (Some(ALL_DATABASES), Some(shown), _) => Some(shown),        (None, Some(shown), _) if no_personal => Some(shown),        (None, Some(shown), crate::shell::scope::DatabaseScope::One { .. }) => Some(shown),        // Joined, and its one database not here yet: the machinery that        // brings it runs (`ARRIVAL_METHODS`) — refusing the fill and the sync        // left Cotton Development waiting for ever (walk) —        // and every call that would read records waits for it, never Personal.        (None, None, one @ crate::shell::scope::DatabaseScope::One { .. })            if !PERSON_METHODS.contains(&method)                && !arrival_method(method) =>        {            return Err(MethodError::new(                "database_not_held",                format!("{} has not arrived on this device yet.", one.said().unwrap_or_default()),            ));        }        (named, _, _) => named,    };    // Owner actions retain their database for the server engine or signed transport.    if method.starts_with("devices.")        || matches!(            method,            "databases.invite"                | "databases.remove"                | "members.admit"                | "members.claimPerson"                | "pairing.pending"                | "pairing.approve"        )    {        if named == Some(ALL_DATABASES) {            return Err(MethodError::new(                "not_a_feed",                "Choose one database for this action.",            ));        }        return page_acts::run(handle, method, request, |method, request| {            answer(handle, method, request)        });    }    // A PICTURE IS STORED IN THE DATABASE ITS CAPTURE NAMES. Whatever names it    // by id — a photo record on a project's Photos list and the caption    // written onto it there, a record's strip, a note's attachments — is in    // that database, and a photo kept in Personal is one that file (and    // everyone else in it) never has: the caption's write answered "That photo    // is no longer here". Personal only when nothing is named, or the feeds'    // word is. The ONE exception is a picture for a new thought, said with    // `into: "thought"`: the thought arrives in Personal (below), and its    // attachments must be in the file it is written into.    if method == "capture.media" {        // A book's `into` is the book its file is for (a book's Add file),        // the capture's own: it goes through (claude-books-gaps walk, 5 Nov        // 2026: every Add file was refused here).        let for_book = request.get("kind").and_then(Value::as_str) == Some("book");        let for_thought = match request.get(CAPTURE_INTO) {            _ if for_book => false,            None | Some(Value::Null) => false,            Some(Value::String(into)) if into == INTO_THOUGHT => true,            Some(other) => {                return Err(MethodError::new(                    "bad_request",                    format!("`into` is \"thought\" for a new thought's picture, or absent for the named database's, not {other}"),                ))            }        };        let mut inner = request.clone();        if let Some(fields) = inner.as_object_mut() {            fields.remove(DATABASE);            if !for_book {                fields.remove(CAPTURE_INTO);            }        }        let into = named.filter(|database| !for_thought && *database != ALL_DATABASES);        let _named = handle.client().name_database(into).map_err(not_held)?;        return page_acts::run(handle, method, &inner, |method, request| {            answer(handle, method, request)        });    }    if PERSON_METHODS.contains(&method) {        let mut inner = request.clone();        if let Some(fields) = inner.as_object_mut() {            fields.remove(DATABASE);        }        let _personal = handle.client().name_database(None).map_err(not_held)?;        return page_acts::run(handle, method, &inner, |method, request| {            answer(handle, method, request)        });    }    let Some(database) = named else {        let _named = handle.client().name_database(None).map_err(not_held)?;        return page_acts::run(handle, method, request, |method, request| {            answer(handle, method, request)        });    };    let mut inner = request.clone();    if let Some(fields) = inner.as_object_mut() {        fields.remove(DATABASE);    }    if database == ALL_DATABASES {        return crate::phone::databases::read_all(handle, method, &inner);    }    // A short read names its database without opening it (`ShortRead`).    let named = if crate::shell::client::ShortRead::named(method).is_some() {        handle.client().name_database_unopened(database)    } else {        handle.client().name_database(Some(database))    };    let _named = named.map_err(|reason| {        if let Some(held) = handle            .client()            .databases()            .ok()            .and_then(|held| held.into_iter().find(|held| held.id == database))        {            crate::shell::refused_copies::observe(&handle.client(), database, &held.name, &reason);        }        not_held(reason)    })?;    page_acts::run(handle, method, &inner, |method, request| {        answer(handle, method, request)    })}/// `capture.media`'s word for a picture that is a new thought's/// ([`INTO_THOUGHT`]): stored in Personal, where the thought arrives, rather/// than in the database the call names.const CAPTURE_INTO: &str = "into";const INTO_THOUGHT: &str = "thought";/// The method table itself, over a request the database has been taken out of.fn answer(handle: &CottonHandle, method: &str, request: &Value) -> Result<Value, MethodError> {    if method == "records.list" {        return crate::phone::records::list_on(handle, request);    }    // The outage happening now is this device's observation, not a stored row.    if method == "records.get"        && request["table"] == "outage"        && request["id"]            .as_str()            .is_some_and(|id| id.starts_with(crate::phone::sync_state::OUTAGE_NOW))    {        let mut answer = crate::phone::sync_state::outage_now(&handle.client())            .filter(|row| row["id"] == request["id"])            .ok_or_else(|| MethodError::new("record_not_found", "that outage has ended"))?;        crate::phone::records::resolve_slips_on(handle, method, request, &mut answer)?;        return Ok(answer);    }    let mut answer = answer_inner(handle, method, request)?;    // Resolve while dispatch still holds the request's database scope.    crate::phone::records::resolve_slips_on(handle, method, request, &mut answer)?;    crate::phone::stamps::on_answer(handle, method, &mut answer);    Ok(answer)}fn answer_inner(    handle: &CottonHandle,    method: &str,    request: &Value,) -> Result<Value, MethodError> {    if let Some(answer) = crate::phone::settings_message_imports::call(handle, method, request) {        return answer.and_then(|answer| {            if method == "records.list" {                crate::phone::settings_list::finish(                    &handle.client(),                    "message_import",                    request,                    answer,                )            } else {                Ok(answer)            }        });    }    match method {        // ── The server ────────────────────────────────────────────────────        // The serving Mac's sender: its line, and Test push.        "device.push" => first_push::status(handle, request),        "device.testPush" => first_push::test_push(handle, request),        "device.pushAck" => first_push::push_ack(handle, request),        // ── Who this Mac is, as a device ──────────────────────────────────        "identity.get" => {            let identity = handle.identity();            Ok(json!({                "deviceId": identity.device_id,                "source": identity.source,                "minted": identity.minted,                "reason": identity.reason,            }))        }        "pairing.pending" => {            crate::phone::devices::call(handle, "devices.pending", request)        }        "members.claimPerson" => crate::phone::member_actions::claim_person(handle, request),        "members.admit" => crate::phone::member_actions::admit(handle, request),        "databases.invite" => {            crate::phone::members::invite(handle, request)        }        "databases.remove" => {            crate::phone::members::remove(handle, request)        }        "pairing.approve" => {            crate::phone::devices::call(handle, "devices.approvePending", request)        }        other @ ("ink.knobs" | "ink.stroke" | "ink.read" | "ink.due" | "ink.edit" | "ink.contest" | "ink.drop" | "ink.clear") => {            crate::methods::ink::call(handle, other, request)        }        "shell.deck" => crate::methods::shell_deck::call(handle, request),        "shell.plus" => crate::methods::shell_deck::plus(handle, request),        "shell.draft" => crate::methods::shell_input::draft(handle, request),        "shell.input" => crate::methods::shell_input::call(handle, request),        "shell.list" => crate::methods::shell_list::call(handle, request),        "shell.fan" => crate::methods::shell_fan::call(handle, request),        "shell.rail" => crate::methods::shell_rail::call(request),        "shell.stream" => crate::methods::shell_stream::call(handle, request),        "shell.home" => crate::methods::shell_home::call(handle, request),        "shell.account" => crate::methods::shell_account::call(handle, request),        "shell.settings" => crate::methods::shell_settings::call(handle, request),        "shell.settings.now" => crate::methods::shell_settings::now(handle, request),        "look" => crate::phone::look::call(handle, request),        m if crate::phone::backup::METHODS.contains(&m) => crate::phone::backup::call(handle, method, request),        "shell.report" => crate::methods::shell_settings::report(handle, request),        "shell.freeUp" => crate::methods::shell_settings::free_up(handle, request),        "shell.today" => crate::methods::shell_today::call(handle, request),        "shell.reading" => crate::methods::shell_reading::call(handle, request),        "shell.undo" => crate::methods::shell_today::undo(handle, request),        "shell.lines" => crate::methods::shell_lines::lines(handle, request),        "count.words" => crate::methods::shell_lines::count_words(handle, request),        "cards.pages" => crate::methods::card_pages::cut(handle, request),        "sync.status" => crate::methods::sync::status(handle, request),        "sync.row" => crate::methods::sync::row(handle, request),        "sync.stuck" => crate::methods::sync::stuck(handle, request),        "sync.stuck.again" => crate::methods::sync::stuck_again(handle, request),        "sync.stuck.letGo" => crate::methods::sync::stuck_let_go(handle, request),        "sync.kept.seen" => crate::methods::sync::kept_seen(handle, request),        "sync.now" => crate::methods::sync::now(handle, request),        "sync.compact" => crate::phone::trim::compact_call(handle, request),        // The parked writes, and a retry. On EVERY build and over the file        // this build holds — a serving Mac parks a peer's refused write        // exactly as a phone does, and `with_file` answers over whichever rail        // this process has.        other @ ("sync.rejected" | "sync.retryRejected") => {            crate::phone::rejected::call(handle, other, request)        }        // ── The route table ──────────────────────────────────────────────        //        // Every screen the app has, as the path string it is reached by. The        // Swift `Route` enum is held TOTAL against this list (design P6), which        // is why it goes through the boundary rather than being a second        // opinion in Swift: a test can only compare two tables it can both see,        // and only one of them compiles on Linux.        //        // It also carries the PUSH VOCABULARY, for the same reason and over the        // same boundary: the Swift notification table is held TOTAL against        // `PUSH_TYPES`, and that comparison needs both lists visible to one        // test host. A method of its own would have been a second way to ask        // one question — this method already exists, and `CLIENT_METHODS` is        // why either build's test host can call it.        "routes.list" => Ok(json!({            "routes": crate::phone::routes::ROUTES,            "count": crate::phone::routes::ROUTES.len(),            "pushTypes": cotton_core::rules::notifications::PUSH_TYPES,            // The two a server sends that the app maps NOTHING for, declared so            // the Swift test asserts a known hole rather than going red on            // arrival — and so the day one of them gets an entry, the hole is            // one line to close. See `rules::notifications`.            "pushTypesUnmapped":                cotton_core::rules::notifications::UNMAPPED_BY_THE_APP,        })),        // ── The phone's three long commands ───────────────────────────────        //        // `join.*` is the way in (P15); `bootstrap.*` is the first copy of the        // file and `migrate.*` the ladder over it (P16). Each returns AT ONCE        // and reports on the `client` event stream.        // A DATABASE BESIDE THE PERSONAL ONE. On the Mac that holds the        // household's databases it is the server's one maker        // (`methods/databases.rs`); on every other device — a phone, a Mac        // that joined — it is minted here with no network and handed to the        // server on the next pass (`phone/databases.rs`).        "databases.create" => {            crate::phone::databases::create(handle, request)        }        // The kits as the personal database keeps them, on this device —        // offline too; the shipped ones while it holds no kit rows yet.        "databases.toolkits" => {            let client = handle.client();            let personal = crate::phone::reads::personal_database(&client)                .map_err(|reason| MethodError::new("toolkits_unreadable", reason))?;            let kits = match personal {                Some(personal) => client.with_file_in(&personal, |file| {                    cotton_tools::toolkits::chooser(Some(file.driver))                }),                None => cotton_tools::toolkits::chooser(None),            }            .map_err(|reason| MethodError::new("toolkits_unreadable", reason))?;            Ok(json!({ "toolkits": kits }))        }        "developer.wearThemeRow" => crate::phone::theme_save::wear_row(handle, request),        "developer.stampStaleCopy" => crate::phone::stale_copy::stamp(handle),        "developer.inventAssistantWriting" => crate::phone::notes_assistant::invent(handle, request),        "developer.inventNoteFiles" => crate::phone::notes_files::invent(handle, request),        "developer.inventServedCopy" => crate::phone::dev_served_copy::invent(handle, request),        "developer.cutNetwork" => crate::phone::dev_served_copy::cut_network(handle, request),        "developer.inventKeptPictures" => crate::phone::dev_kept_pictures::invent(handle, request),        "developer.inventWhatsappFaces" => crate::phone::dev_whatsapp_faces::invent(handle, request),        "developer.inventSenders" => crate::phone::dev_senders::invent(handle, request),        "developer.inventPeopleWalk" => crate::phone::dev_people_walk::invent(handle, request),        "developer.checkKeptPictures" => crate::phone::dev_kept_pictures::check(handle, request),        "developer.resealKept" => crate::phone::dev_kept_pictures::reseal(handle, request),        "developer.inventMail" => crate::phone::chat_app::mail::invent(handle, request),        "developer.revokeWhatsapp" => crate::phone::dev_revoke::revoke(handle, request),        "developer.fakeMac" => crate::phone::dev_fake_mac::answer(handle, request),        "developer.lookServedBefore" => crate::phone::dev_look::served_before(handle, request),        "developer.stuckChange" => crate::phone::dev_unsent::stuck_change(handle, request),        "databases.delete" => crate::phone::database_bin::act(handle, request, false),        "databases.restore" => crate::phone::database_bin::act(handle, request, true),        "databases.show" => crate::phone::databases::show(handle, request),        "databases.present" => crate::phone::joined_places::present(handle, request),        "databases.leave" => crate::phone::databases::leave(handle, request),        "databases.hide" => crate::phone::databases::hide(handle, request),        "business.sync" | "business.pages" | "business.code" | "business.signIn" | "business.signOut" | "business.act" => {            crate::phone::business::call(handle, method, request)        }        "gettingIn.screen" | "gettingIn.again" => crate::phone::getting_in::call(handle, method, request),        "personal.ask" | "personal.askPoll" | "personal.handoff" | "signin.asks" | "signin.show" | "signin.approve" | "signin.approveSibling" | "signin.siblingTicket" | "signin.refuse" => crate::phone::signin_approval::call(handle, method, request),        "personal.passkeyBegin" | "personal.passkeySignIn" | "signin.passkeys" | "signin.passkeyOptions" | "signin.passkeyAdd" | "signin.passkeyRemove" => crate::phone::account_passkey::call(handle, method, request),        "account.delete" | "account.deleteCode" | "account.deletePage" | "account.forget" | "account.keep" | "account.leave" => crate::phone::account_delete::call(handle, method, request),        "restore.points" | "restore.begin" | "restore.progress" | "restore.cancel" | "restore.after" => crate::phone::restore::call(handle, method, request),        "personal.code" | "personal.signIn" | "personal.connect" | "personal.adopt" | "personal.adoptStatus" | "personal.standLocal" | "personal.remove" => crate::phone::personal_object::call(handle, method, request),        "bootstrap.start"        | "bootstrap.status"        | "migrate.status"        | "sync.foreground"        | "sync.background"        | "workspace.startLocal" => crate::phone::commands::call(handle, method, request),        // ── The log ───────────────────────────────────────────────────────        // What was said BEFORE anyone was listening. Every line also goes out on        // the event stream as it happens, so nothing polls this.        "log.lines" => {            Ok(serde_json::to_value(handle.log().lines())                .expect("a log line is always serialisable"))        }        // ── This build ────────────────────────────────────────────────────        // The store schema this build writes, the built-in definitions it        // ships and the version the app opened it with. The phone has no        // server status to read them from; Cotton Dev's corner and About show        // them. The build number and What's new are the app bundle's own.        // What the app says of itself for the device's reported state: its        // build and commit, the databases its sheet lists, its open card's        // problem (`shell::diagnostics`).        "diagnostics.say" => Ok(crate::shell::diagnostics::say(request)),        // The report a session reads instead of asking the owner        // (`shell::report`): filed in the personal database, like Feedback.        "diagnostics.report" => crate::shell::report::report(handle, request),        // The Debug group at the end of This phone / This Mac.        "diagnostics.debug" => crate::shell::diagnostics::debug(handle),        "diagnostics.removeCopy" => crate::shell::diagnostics::remove_copy(handle, request),        "build.facts" => Ok(json!({            "schemaVersion": cotton_store::schema::ddl::SCHEMA_VERSION,            "definitionsRevision": cotton_core::definitions::BUILTIN_DEFINITIONS_HASH,            "appVersion": handle.app_version(),        })),        // ── The data directory ────────────────────────────────────────────        "datadir.status" => {            let layout = handle.layout();            Ok(json!({                "path": handle.data_dir(),                "exists": handle.data_dir().exists(),                "appVersion": handle.app_version(),                "paths": {                    "env": layout.env_file(),                    "serverLog": layout.server_log(),                    "registry": layout.registry_db(),                    "identity": layout.identity_dir(),                    "client": layout.client_dir(),                    "media": layout.media_dir(),                    "thumbs": layout.thumbs_cache_dir(),                },            }))        }        // The six writes no tool may make — the reasons are on        // `CLIENT_METHODS` above and in each module's own header. They run        // through the SAME `Ctx::phone`, the same writer, the same outbox and        // the same `data` event as `write` does; only the body differs.        "capture.media" => crate::phone::media::capture(handle, request),        // A Camera tool shot.        "camera.shot" => crate::phone::camera::shot(handle, request),        // A person's photograph. A method of its own rather than a `kind` on        // `capture.media`, for the reason that method's refusal already        // states out loud: an avatar belongs to a row something else wrote        // first, and `capture.media` mints its own.        "capture.avatar" => crate::phone::media::capture_avatar(handle, request),        "dictation.create" => crate::phone::dictation::create(handle, request),        // Voice: the core's half of dictation and commands (`phone::voice`, whose header is the contract).        method if method.starts_with("voice.") => crate::phone::voice::call(handle, method, request),        // "Export everything" — the way out of your own database. The ANSWER IS        // A PATH and a count, never the document: a whole database as a string        // crossing this boundary is the jetsam kill build 106 already paid for,        // and `read.mediaPath` answers a path for the same reason.        "export.build" => crate::phone::export::build(handle, request),        // The Cotton package: a path in or out, never the bytes.        "package.export" => crate::phone::package::export(handle, request),        // The open bundle: one kit as the folder tree other apps open, a path        // out and never the bytes.        "package.exportOpen" => crate::phone::package::export_open(handle, request),        "package.import" => crate::phone::package::import(handle, request),        "usage.record" => crate::phone::usage::record(handle, request),        // A shaken report to Cotton's own database, kept until it is taken (`phone::feedback_send`).        "feedback.send" | "feedback.flush" => crate::phone::feedback_send::call(handle, method, request),        // A WhatsApp `_chat.txt` export the app was handed, read on this phone        // and written into its own replica through the applier the Mac's        // ingest sources use. A method, not a tool: no assistant may import a        // file off this phone's disk, and the answer names the thread it made.        "import.whatsappExport" => crate::phone::whatsapp_import::import(handle, request),        other if crate::phone::code::METHODS.contains(&other) => {            crate::phone::code::call(handle, other, request)        }        // The owner's acts on a domain: the serving Mac does each.        other if crate::phone::domains::METHODS.contains(&other) => {            crate::phone::domains::call(handle, other, request)        }        // Describe one picture: the serving Mac holds the model key and the bytes.        other if crate::phone::media_describe::METHODS.contains(&other) => {            crate::phone::media_describe::call(handle, other, request)        }        // The raw terminal (Cotton note "The Code tool — why a Mac holds the sessions"). On BOTH builds:        // the Mac dials its own helper and every other device dials that Mac        // over `/v1/sessions/attach`, and which one is `phone::terminal`'s        // decision rather than the app's.        other if crate::phone::terminal::METHODS.contains(&other) => {            crate::phone::terminal::call(handle, other, request)        }        "media.ensure" => crate::phone::media::ensure(handle, request),        // A film's stream, minted at the object; and its place and kept        // bundle on this device alone (`phone::films`).        method if crate::phone::films::METHODS.contains(&method) => crate::phone::films::call(handle, method, request),        method if crate::phone::cinemas_home::METHODS.contains(&method) => crate::phone::cinemas_home::call(handle, method, request),        method if crate::phone::cinemas_shared::METHODS.contains(&method) => crate::phone::cinemas_shared::call(handle, method, request),        method if crate::phone::cinemas_home::more::METHODS.contains(&method) => crate::phone::cinemas_home::more::call(&handle.client(), method, request),        // What this device keeps of a book's file, and the reader opening one.        method if crate::phone::books::METHODS.contains(&method) => crate::phone::books::call(handle, method, request),        method if crate::phone::reader::METHODS.contains(&method) => crate::phone::reader::call(handle, method, request),        method if crate::phone::songs::METHODS.contains(&method) => crate::phone::songs::call(handle, method, request),        "shell.player" => crate::phone::shell_player::call(&handle.client(), request),        method if crate::phone::money::METHODS.contains(&method) => crate::phone::money::call(handle, method, request),        method if crate::phone::film_intake::METHODS.contains(&method) => crate::phone::film_intake::call(handle, method, request),        method if crate::phone::film_subtitle_file::METHODS.contains(&method) => crate::phone::film_subtitle_file::call(handle, method, request),        method if crate::phone::song_intake::METHODS.contains(&method) => crate::phone::song_intake::call(method, request),        method if crate::phone::film_player::METHODS.contains(&method) => crate::phone::film_player::call(&handle.client(), method, request),        method if crate::phone::object_acts::METHODS.contains(&method) => crate::phone::object_acts::call(handle, method, request),        // A detail view opened an original. The LRU stamp the budgeted phone        // cache orders by — see `phone::media::viewed` for why a grid must        // never call it.        "media.viewed" => crate::phone::media::viewed(handle, request),        // Where each of these files is on its way up (MEDIA DRAIN 1): what a        // screen counts "kept" by, per file, off the object's own answer.        "media.uploads" => crate::phone::media::uploads(handle, request),        // The network the phone is on (MEDIA DRAIN 1 item 2): Wi-Fi-only files wait off Wi-Fi.        "media.network" => crate::phone::media::network(handle, request),        // Cotton Meetings (`phone::meetings_app`, apps/meetings/CORE.md).        method if crate::phone::meetings_app::METHODS.contains(&method) => crate::phone::meetings_app::call(handle, method, request),        "page.save" => crate::phone::page::save(handle, request),        "share.fetchLinks" => crate::phone::share_fetch::fetch_links_method(handle, request),        "share.door" => crate::phone::share_door::door_method(handle, request),        "link.open" => crate::phone::link_open::open_method(handle, request),        "notes.shared" => crate::phone::notes_share::shared(handle, request),        method if crate::phone::notes::METHODS.contains(&method) => crate::phone::notes::call(handle, method, request),        method if crate::phone::story::METHODS.contains(&method) => crate::phone::story::call(handle, method, request),        method if crate::phone::days::METHODS.contains(&method) => crate::phone::days::call(handle, method, request),        method if crate::phone::contacts_io::METHODS.contains(&method) => crate::phone::contacts_io::call(handle, method, request),        method if crate::phone::health::METHODS.contains(&method) || crate::phone::health_app::METHODS.contains(&method) => crate::phone::health::call(handle, method, request),        // A person's city, filled in from their zone by Cotton itself. A        // method rather than a tool because nobody ASKS for it: the app runs        // it on each foreground, and every fill inside it is `update_person`,        // the tool an assistant would have called (`phone::people_city`).        method if crate::phone::share_sheet::METHODS.contains(&method) => crate::phone::share_sheet::call(handle, method, request),        method if crate::phone::circle::METHODS.contains(&method) => crate::phone::circle::call(handle, method, request),        "people.accept" | "people.add" | "people.block" | "people.pick" | "people.refuse" | "people.remove" | "people.unblock" => crate::phone::your_people::call(handle, method, request),        "people.fillCities" => crate::phone::people_city::call(handle, request),        // B7: whom the Mac owes a print, and from which face (`phone::people_prints`).        "people.printsNeeded" => crate::phone::people_prints::call(handle, request),        "people.unfillCities" => crate::phone::people_city::call_unfill(handle, request),        // The local phrase parser (#1284). The request is `parse_phrase`'s        // arguments and the answer the tool's own, through the same handler an        // assistant reaches (`phone::phrase`).        "phrase.parse" => crate::phone::phrase::call(&handle.client(), request),        // A PROJECT'S STANDING CONVERSATION, opened or found. A method for        // `session.create`'s reason: what it does is put a session on one of        // the owner's Macs, and only the owner asks for that        // (`crate::phone::conversation`).        "project.conversation" => crate::phone::conversation::conversation(handle, request),        "push.forget" => crate::phone::push::forget(handle, request),        // Every method seal answers, from its own list, so a new one cannot be        // listed and go unrouted (seal.heldKey was, 12 Nov 2026).        m if crate::phone::seal::METHODS.contains(&m) => crate::phone::seal::call(handle, method, request),        "asks.allow" | "asks.card" | "asks.refuse" => crate::phone::owner_asks::call(handle, method, request),        "unlock.allow" | "unlock.allowAll" | "unlock.card" | "unlock.decline" | "unlock.end" | "unlock.reads" | "unlock.windows" => crate::phone::unlock::call(handle, method, request),        "assistant.askEachTime" | "assistant.connect" | "assistant.remove" | "assistant.scope" | "assistant.screen" | "assistant.stop" => crate::phone::assistants::call(handle, method, request),        "assistant.keys" | "assistant.key" | "assistant.allow" => crate::phone::assistant_keys::call(handle, method, request),        // The way back in: a recovery code, a platform key (`crate::phone::recovery`).        m if crate::phone::recovery::METHODS.contains(&m) => crate::phone::recovery::call(handle, method, request),        m if crate::phone::recovery_circle::METHODS.contains(&m) => crate::phone::recovery_circle::call(&handle.client(), method, request),        m if crate::phone::recovery_screens::METHODS.contains(&m) => crate::phone::recovery_screens::call(&handle.client(), method, request),        "reminders.desired" => crate::phone::reminders::call(handle, request),        "reminders.reconcile" => crate::phone::reminders::reconcile_call(handle, request),        // The owner asks for a session, and takes one back. Methods because        // asking a Mac to run an agent is the owner's own request and no        // assistant may make one. ONE OBJECT (v23) — what        // this creates is the `cotton_sessions` row the session then runs on.        "session.create" => crate::phone::session_queue::create(handle, request),        "session.withdraw" => crate::phone::session_queue::withdraw(handle, request),        "session.resume" => crate::phone::session_queue::resume(handle, request),        // ── The phone's own two families (design P3, P4) ─────────────────        //        // `write` is one method taking a TOOL NAME: the app writes by calling        // the same handlers an assistant calls, which is what makes "one        // implementation of who wins" a compiled function rather than a claim        // about two ports of one algorithm. It also means the app cannot invent        // a write vocabulary the assistants do not have — a screen that needs a        // verb has to add the tool.        "write" => crate::phone::write(handle, request),        "tools.add" | "tools.export" | "tools.import" | "tools.list" | "tools.remove" => {            crate::phone::tools::call(handle, method, request)        }        // ── The table definitions and the generic verbs (rebuild item 3) ────        //        // The names in `phone::records::METHODS`: `definitions.board`,        // `definitions.theme`, `definitions.contributors`,        // `definitions.tables`, `definitions.tools`, and one `records.*` per generic verb, each of        // which IS its MCP tool — the request is the tool's arguments and the        // answer the tool's own, over the owner's context (byline `user`).        // A command naming an app method runs it on this handle.        method if crate::phone::settings_message_imports::METHODS.contains(&method) => {            crate::phone::settings_message_imports::call_method(handle, method, request)        }        "records.command" => crate::phone::records::command_on(handle, request),        "records.spoken" => crate::phone::records::spoken_on(handle, request),        "records.move" => crate::phone::record_moves::call(handle, request),        method if crate::phone::device_preferences::METHODS.contains(&method) => {            crate::phone::device_preferences::call(handle, method, request)        }        method if crate::phone::rekey::METHODS.contains(&method) => {            crate::phone::rekey::call(handle, method, request)        }        method if crate::phone::code_preferences::METHODS.contains(&method) => {            crate::phone::code_preferences::call(handle, method, request)        }        "records.live" => crate::phone::records_live::call(handle, request),        "records.page" => crate::phone::records::page_on(handle, request),        method @ ("records.get" | "records.delete" | "records.reorder") => {            if let Some(answer) =                crate::phone::settings_devices::records_read(handle, method, request)            {                return answer;            }            if let Some(answer) = crate::phone::metering::records_read(handle, method, request) {                return answer;            }            if let Some(answer) =                crate::phone::records::settings_tables::call_on(handle, method, request)            {                return answer;            }            crate::phone::records::call(&handle.client(), method, request)        }        "records.update" => {            if let Some(answer) =                crate::phone::records::settings_tables::call_on(handle, "records.update", request)            {                return answer;            }            if let Some(answer) = crate::phone::settings_devices::update(handle, request)? {                return Ok(answer);            }            crate::phone::records::call(&handle.client(), "records.update", request)        }        // The one optional live Device read. The generic device rows remain        // synced reads and do not acquire this Mac's writer lock.        "device.facts" => crate::phone::settings_devices::facts(handle, request),        // A Records thread's two acts, which its page offers as commands        // (`records.command` reaches the same door) — the record and its link        // to the thread in one write.        method @ (crate::phone::record_acts::RECORD_AS_TRANSACTION        | crate::phone::record_acts::ADD_TO_CALENDAR) => {            crate::phone::record_acts::call(handle, method, request)        }        // This Device's Add / Remove sample records, as its page's commands.        method @ (crate::phone::samples::ADD | crate::phone::samples::REMOVE) => {            crate::phone::samples::call(handle, method, request)        }        "tools.act" => crate::phone::tool_acts::call(&handle.client(), request),        "tools.acts" => crate::phone::tool_acts::acts(&handle.client(), request),        "shell.opened" if request["step"] == "pick" => crate::methods::shell_input::pick(handle, request),        "shell.opened" => crate::phone::opened::call(&handle.client(), request),        "cards.birthdays" => crate::phone::today_deck::birthdays(&handle.client(), request),        "cards.moneyDue" => crate::phone::today_deck::money_due(&handle.client(), request),        "cards.factLabels" => crate::phone::today_deck::fact_labels(&handle.client(), request),        "cards.repeat" => crate::phone::date_choices::repeat(&handle.client(), request),        "cards.when" => crate::phone::card_when::when(&handle.client(), request),        // A Cinemas list that is shared follows its change to its members (CONTACT KINDS 3).        "groups.update" => {            let answer = crate::phone::records::call(&handle.client(), "groups.update", request)?;            crate::phone::share_sheet::list_changed(handle, request);            Ok(answer)        }        other if crate::phone::records::METHODS.contains(&other) => {            crate::phone::records::call(&handle.client(), other, request)        }        // ── 4h: the owner's own server, and the five settings writes ──────        //        // Matched by PREFIX for the same reason the read family is: the names        // live beside their route in each module's own `METHODS`, and a second        // list of them here would be drift. Five families ask the server over        // the signed transport (`phone::owner`); `settings.*` are        // the five rows the tool surface owes no verb, written through the one        // authoring path.        "device.serveFrom" => crate::phone::serve_from::call(handle, request),        "device.becomeRunner" => crate::phone::become_runner::call(handle, request),        other if other.starts_with("devices.") => {            crate::phone::devices::call(handle, other, request)        }        other if other.starts_with("google.") => crate::phone::google::call(handle, other, request),        other if other.starts_with("spotify.") => crate::phone::spotify::call(handle, other, request),        other if other.starts_with("whatsapp.") => {            crate::phone::whatsapp::call(handle, other, request)        }        // MATCHED BEFORE the `settings.` prefix below, because it is not one        // of that module's writes: a media budget is about THIS device's disk,        // so it is a file beside `connection.json` rather than a row through        // the outbox. See `phone::media::set_media_budget`.        "storage.freeUp"        | "storage.keepRule"        | "storage.keptSpace"        | "storage.measure"        | "storage.setMacFiles" => crate::phone::storage::dispatch(handle, method, request),        // Opening a record this device does not keep (`phone::keep`).        // …and settling its copy with its keep rules.        "keep.open" | "keep.reconcile" | "keep.audience" => {            crate::phone::keep::dispatch(handle, method, request)        }        // …and what it keeps, as its own screen reads and changes it.        other if crate::phone::keep_rules::METHODS.contains(&other) => {            crate::phone::keep_rules::dispatch(handle, method, request)        }        "settings.mediaBudget" => crate::phone::media::set_media_budget(handle, request),        other if other.starts_with("settings.") => {            crate::phone::settings_writes::call(handle, other, request)        }        other if other.starts_with("vault.") => crate::phone::vault::call(handle, other, request),        other if crate::phone::secrets_app::METHODS.contains(&other) => crate::phone::secrets_app::call(&handle.client(), other, request),        other if crate::phone::contacts_app::METHODS.contains(&other) => crate::phone::contacts_app::call(&handle.client(), other, request),        other if crate::phone::contacts_same::METHODS.contains(&other) => crate::phone::contacts_same::call(&handle.client(), other, request),        other if crate::phone::data_app::METHODS.contains(&other) => crate::phone::data_app::call(&handle.client(), other, request),        other if crate::phone::contacts_groups::METHODS.contains(&other) => crate::phone::contacts_groups::call(&handle.client(), other, request),        other if crate::phone::albums_shared::METHODS.contains(&other) => crate::phone::albums_shared::call(&handle.client(), other, request),        other if crate::phone::albums_app::METHODS.contains(&other) => crate::phone::albums_app::call(&handle.client(), other, request),        other if crate::phone::albums_faces::METHODS.contains(&other) => crate::phone::albums_faces::call(other, request),        other if other.starts_with("passkey.") => crate::phone::passkeys::call(handle, other, request),        other if other.starts_with("password.") => crate::phone::passwords::call(handle, other, request),        other if other.starts_with("keys.") => crate::phone::keys::call(handle, other, request),        other if other.starts_with("calls.") => crate::phone::calls::call(handle, other, request),        "chat.you" => crate::phone::chat_you::call(handle, request),        method if crate::phone::chat_recordings::METHODS.contains(&method) => crate::phone::chat_recordings::call(handle, method, request),        "chat.you.now" => crate::phone::chat_you::now(handle, request),        method if crate::phone::chat_app::mail::post::METHODS.contains(&method) => crate::phone::chat_app::mail::post::call(&handle.client(), method, request),        method if crate::phone::sites::handles(method) => crate::phone::sites::call(handle, method, request),        other if other.starts_with("chat.") => crate::phone::cotton_chat::call(handle, other, request),        other if other.starts_with("send.") => crate::phone::cotton_send::call(handle, other, request),        other if other.starts_with("shared.") => crate::phone::shared_list::call(handle, other, request),        // A method that exists only while the crate's own tests run: it proves        // the boundary catches a panic instead of unwinding into Swift, and it        // cannot ship because `cfg(test)` is not compiled into the staticlib.        #[cfg(test)]        "debug.panic" => panic!("{}", request["message"].as_str().unwrap_or("a panic")),        // `read.<name>` — one method per screen query (design P4). Matched by        // PREFIX rather than by forty arms, because the names live in        // `phone::reads::READS` beside the screen each one serves, and a second        // list of them here would be the drift that table exists to prevent.        other if other.starts_with("read.") => crate::phone::read(handle, other, request),        other => Err(MethodError::new(            "unknown_method",            format!("this core does not answer `{other}`"),        )        // `.as_slice()`: serde stops implementing `Serialize` for arrays        // at 32 elements, and this list passed that.        .with_details(json!({ "known": methods() }))),    }}/// The method lists themselves.#[cfg(test)]mod partition_tests {    use super::*;    use std::collections::BTreeSet;    fn set(names: &[&'static str]) -> BTreeSet<&'static str> {        names.iter().copied().collect()    }    #[test]    fn the_client_list_is_the_whole_list() {        assert_eq!(            set(CLIENT_METHODS),            set(ALL_METHODS),            "ALL_METHODS and CLIENT_METHODS disagree — one of the two lists is stale"        );    }    /// RULE: Each method is advertised once per list so discovery never offers duplicate capabilities; display order is not part of the ABI.    #[test]    fn every_list_names_nothing_twice() {        for (label, list) in [            ("ALL_METHODS", ALL_METHODS),            ("CLIENT_METHODS", CLIENT_METHODS),        ] {            assert_eq!(set(list).len(), list.len(), "{label} names something twice");        }    }    #[test]    fn this_build_answers_every_client_method() {        let answered: BTreeSet<String> = methods().into_iter().collect();        for &client in CLIENT_METHODS {            if client == "read" {                continue;            }            assert!(                answered.contains(client),                "{client} is the client's and is missing from this build"            );        }        assert!(            answered.iter().any(|name| name.starts_with("read.")),            "every build offers the read family by name"        );        assert!(answered.contains("write"));    }    #[test]    fn the_read_family_is_expanded_rather_than_offered_as_a_prefix() {        // `read` stands for the family in the PARTITION list, because a        // partition is about which build owns a name. What an app is told is        // the real list — a method named `read` answers nothing.        let answered: BTreeSet<String> = methods().into_iter().collect();        assert!(!answered.contains("read"), "`read` is not a method");    }}