[workspace]resolver = "2"members = ["cotton-rules","cotton-rules-wasm","cotton-store","cotton-conformance","cotton-core","cotton-tools","cotton-client","cotton-ffi","cotton-session-host","cotton-gen","cotton-android-jni","cotton-mover","cotton-mac","cotton-mac-ffi",][workspace.package]edition = "2021"license = "AGPL-3.0-only"publish = false[workspace.dependencies]rusqlite = { version = "0.41", features = ["bundled", "functions", "hooks"] }sha2 = "0.10"hex = "0.4"serde = { version = "1", features = ["derive"] }# `float_roundtrip`: a receipt's number is parsed back to the exact f64 it was# written from — without it `40.662800000000004` reads as `40.6628`, and a# receipt holding it fails its own canonical check (`canonical::decode`).serde_json = { version = "1", features = ["preserve_order", "float_roundtrip"] }thiserror = "2"anyhow = "1"base64 = "0.22"ed25519-dalek = { version = "2", features = ["rand_core", "zeroize"] }subtle = "2"rand = "0.8"axum = { version = "0.8", features = ["ws"] }tokio = { version = "1", features = ["full"] }tower = { version = "0.5", features = ["util"] }tower-http = { version = "0.6", features = ["cors"] }hyper = { version = "1", features = ["server", "http1"] }hyper-util = { version = "0.1", features = ["tokio", "server", "server-graceful"] }http-body-util = "0.1"hmac = "0.12"# `http2` is NOT optional here: APNs speaks HTTP/2 EXCLUSIVELY, and a client# built without it never offers h2 over ALPN, so every push fails at the# protocol rather than at the payload. The TypeScript reached for `node:http2`# for exactly this reason — undici is HTTP/1.1 only.# `stream` is NOT optional either: a release asset is up to a couple of# gigabytes of database backup and `repos/mirror.rs` streams it chunk by chunk# onto the disk. Without it the only download shape reqwest offers is the whole# body in memory, which is the one thing# Cotton note "First launch on a new phone — the whole database, downloaded" forbids by name.reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json", "http2", "stream"] }tracing = "0.1"tracing-subscriber = { version = "0.3", features = ["env-filter"] }lru = "0.12"tempfile = "3"# DEFLATE, streaming, in both directions — the snapshot goes out gzipped and the# client inflates it as it writes it to disk. `default-features = false` +# `rust_backend` is `miniz_oxide` and no C: the phone links this crate through# `cotton-client`, and a zlib-sys build is not something an iOS archive should# have to find.flate2 = { version = "1", default-features = false, features = ["rust_backend"] }async-trait = "0.1"# The snapshot and object routes hand back a FILE, never bytes: `ReaderStream`# is the seam between a `tokio::fs::File` and an axum body.tokio-util = { version = "0.7", features = ["io"] }futures-util = { version = "0.3", default-features = false, features = ["std"] }# The Google token store is AES-256-GCM under a scrypt-derived key, because a# TypeScript server wrote every `_google_tokens` row already on disk with# Node's `createCipheriv("aes-256-gcm")` and `scryptSync` — the algorithm and# its parameters are a FILE FORMAT here, not a choice.aes-gcm = "0.10"scrypt = { version = "0.11", default-features = false, features = ["std"] }# A WebSocket CLIENT, for the live suites.tokio-tungstenite = { version = "0.26", default-features = false, features = ["connect", "handshake"] }# WHATWG URL semantics: `sanitizePreviewUrl` strips credentials and refuses# anything but https, and a redirect is resolved against the hop it came from.url = "2"# The Open Graph tags are flat metadata in `<head>` and the attribute order# varies, so the TypeScript reads them with two regexes rather than a DOM.regex = "1"# OOXML is a zip: a `.docx` is `word/document.xml` and a `.xlsx` a folder of# sheets, both DEFLATEd. The TypeScript reads them with fflate.zip = { version = "9", default-features = false, features = ["deflate"] }# MuPDF, built from source. Measured on the build Mac at 37.5 s wall with# CARGO_BUILD_JOBS=3, so no fallback reader was needed: `pdfium-render` wants a# prebuilt binary alongside the server and `lopdf` + `pdf-extract` cannot# authenticate an encrypted document, which is the one thing this pipeline# exists to do.mupdf = "0.5"# THE RUNNER PROTOCOL, and nothing else. `prost` is the codec for the seven# unary Connect RPCs a stock CI runner speaks (`cotton-server/src/ci/`), and# `prost-types` is where `google.protobuf.Struct` and `Timestamp` come from —# the `github` context a job is handed is a `Struct`, so this is a RUNTIME# dependency of the server, not only of the generator.prost = "0.14"prost-types = "0.14"# The generator half, build-dependencies only. `protox` stands in for `protoc`# so no machine that compiles this workspace needs a protobuf compiler# installed — the argument is in `cotton-server/build.rs`.prost-build = "0.14"protox = "0.9"# The CI workflow dialect is YAML, and the parser walks a `Value` by hand# rather than deriving: every construct Cotton refuses is refused BY NAME with# a sentence naming the key and the job, which a `Deserialize` impl cannot say.# `serde_yaml` is unmaintained upstream (0.9.34+deprecated) and named here# anyway: it is pure Rust, its `Mapping` keeps document order (which is the# order the jobs and steps were written in), and the alternative forks are# younger than the crate they forked. If it ever has to be replaced, the whole# dependency is one `from_str` call in `ci/workflow.rs`.serde_yaml = "0.9"# The APNs provider token is an ES256 JWT over P-256 — Apple's only auth scheme# for a token-based connection, and the one signature this workspace makes that# is NOT Ed25519. The `.p8` Apple issues is an unencrypted PKCS#8 PEM.p256 = { version = "0.13", default-features = false, features = ["ecdsa", "pkcs8", "pem", "std"] }# READING a bare git repository — trees, blobs, the log and a commit's diff.# Pure Rust, no C toolchain and no OpenSSL, so the slice that compiles for the# Mac compiles for iOS unchanged (`git2`'s `https` feature does not build for# `aarch64-apple-ios` at all, and libgit2 1.9 cannot speak protocol v2).## `default-features = false` and FOUR features, each because something reads# with it: `sha1` (the object hash this product's repositories are written# with), `max-performance` (the parallel pack traversal and the LRU pack# caches — `max-control`, and its own docs say "no C toolchain is involved"),# `revision` (`rev_walk`, which is the log), `blob-diff` (a commit's hunks).## WHAT IS DELIBERATELY NOT HERE. No `blocking-http-transport-*` and no# `blocking-network-client`: git is DIALLED through the spawned binary# (`repos/git.rs`), because neither gitoxide nor libgit2 can write a bundle or# serve upload-pack, and a second network client for fetch alone would be a# second answer to "who talks to the origin". No `extras` either — the default# set pulls `interrupt`, which is `signal-hook` inside a server that already# owns its own signal handling, plus the whole worktree and status machinery a# bare clone never touches.gix = { version = "0.87", default-features = false, features = ["sha1", "max-performance", "revision", "blob-diff"] }[profile.release]codegen-units = 4# The Worker's rules module (`pnpm rules:wasm`, crates/cotton-rules-wasm): a# download every cold isolate instantiates, so it is built for size, linked# whole, and aborts on panic (the boundary answers a Result, never panics).# Not stripped: the name section stays, so a trap's stack names functions.[profile.wasm]inherits = "release"opt-level = "s"lto = truecodegen-units = 1panic = "abort"# ── THE ANDROID LIBRARY'S PROFILE (6 Nov 2026) ─────## `libcotton_android_jni.so` is most of Books' APK (71.5 MB of 90.6 MB at the# release profile), and every byte of it is a download a person waits for on# a phone. So the Android build (`cargo ndk … build --profile android`) is# optimised for size, linked whole and stripped; measured before/after in the# lane's notes. `panic` STAYS `unwind`: the C ABI's contract is that no panic# crosses (`cotton-ffi/src/ffi.rs`, every body under `catch_unwind`), and an# abort would turn a refused call into a killed app.[profile.android]inherits = "release"opt-level = "z"lto = "fat"codegen-units = 1strip = true# ── THE iPHONE CORE'S PROFILE (14 Nov 2026) ───────────────## The device slice an archive links (`scripts/build-xcframework.sh` without# `--debug`). Books build 11's binary was 117 MB against Android's 58 MB core:# the slice was built at `release` (four codegen units, no cross-crate LTO),# so the linker kept whole objects of code the phone never calls. Linked whole# here, as Android's is; measured before and after in the lane's report.# `panic` STAYS `unwind` for the C ABI's reason the Android profile gives.## BUILT FOR SIZE, AT "s" AND NOT "z" (15 Nov 2026). Books'# Release device binary, Rust and Swift together: `__text` 61.5 MB at# opt-level 3, 53.2 MB at "s", 43.6 MB at "z". The speed was measured on# a Mac (aarch64-apple-darwin, this profile, the level by# CARGO_PROFILE_IOS_OPT_LEVEL, seven runs each, interleaved), median against# opt-level 3:## 3 "s" "z"# shell.list Owed, first ask, 50k rows 70.9 ms 72.7 (+2.6%) 99.3 (+40%)# a copy's birth, the whole kit 742 ms 766 (+3.2%) 975 (+31%)# a sync pass, 5,000 rows in ten tables 454 ms 479 (+5.6%) 680 (+50%)## "z" costs a third to a half of the speed for the 9.6 MB more it saves;# "s" saves 8.3 MB and keeps the speed within 6%. The `cc` crate compiles the bundled SQLite at the# profile's level too, so it is at -Os here.## NOT STRIPPED HERE. `strip` does nothing to a staticlib (rustc strips only# what it links), and the archive strips the linked app itself after dsymutil# has copied the symbol table into the dSYM, which is what symbolicates a# crash's Rust frames: this profile carries no debug info, so the names are# all a dSYM has of the core.[profile.ios]inherits = "release"opt-level = "s"lto = "fat"codegen-units = 1# ── THE ANDROID LIBRARY'S DEBUG PROFILE (8 Nov 2026)## What the Gradle debug variant and android.yml build (`--profile# android-debug`): the dev profile (opt-level 0, no LTO, and the dev profile's# optimised scrypt, salsa20 and SQLite below) with no debug info, the fastest# core that compiles and links. CI needs a core that links and a debug APK# whose JVM unit tests run, never the release profile's fat LTO (about twelve# minutes a run). The release variant and the Play verbs keep `android`; the two# land in different jniLibs (src/debug, src/release) so they never swap.[profile.android-debug]inherits = "dev"debug = false# ── THE ONE THING A DEBUG BUILD MUST NOT COMPILE AT `opt-level = 0` ─────────## `google::crypto` derives its AES key with scrypt at Node's `scryptSync`# defaults — N=16384, r=8, p=1 — deliberately, so a token this server seals is# one the TypeScript could open, and deliberately NOT memoised# (`crates/cotton-server/src/google/crypto.rs`). Production pays it once per# refresh token per sweep, which is what scrypt is for. The TESTS pay it on# every seeded grant and every worker pass, and they pay it UNOPTIMISED: scrypt# is a tight integer loop over a 16 MB working set, which is exactly the shape# `opt-level = 0` punishes by an order of magnitude.## Measured on run 181: `sample(1)` on# `google::token_store::token_store_tests::a_reconnect_clears_the_cursor_and_keeps_a_known_zone`# put **62% of its sampled frames inside `scrypt::scrypt`** — romix, block_mix,# the salsa20 core — and no SQLite at all. Twelve of the workspace's slowest# unit tests are scrypt-bound the same way (`google::migrate`,# `google::token_store`, `vault::boot`'s legacy rows, `assistant::secrets`,# `auth`), and the Gmail and Calendar suites pay it per pass on top of their own# fixtures: ~480 test-seconds of the workspace's 4,475 pass through this loop.## So these two are built optimised even in a debug build.## scrypt the derivation itself — romix and block_mix# salsa20 its core permutation, where the samples actually land## TWO, AND NOT `profile.dev.package."*"`. A blanket override optimises five# hundred dependencies, and it also invalidates them: a cold branch's build —# the thing the per-branch target directory and sccache exist to shorten —# would get materially longer for a win that lives in one loop. These two are# LEAVES with almost nothing downstream of them, so the rebuild this change# costs a warm target directory is those two crates and what links them, once.# `sha2` and `pbkdf2` are deliberately NOT here for that reason: scrypt calls# them twice each against 16,384 rounds of romix, and half the workspace# depends on `sha2`.## Nothing about the bytes changes. An optimised scrypt and a debug scrypt agree# on every output, or scrypt is broken — and `google::crypto`'s cross-language# fixture test is what would say so.[profile.dev.package.scrypt]opt-level = 3[profile.dev.package.salsa20]opt-level = 3# ── AND SQLITE, BECAUSE EVERY TEST GOES THROUGH IT ──────────────────────────## `rusqlite`'s `bundled` feature compiles the SQLite amalgamation from C inside# `libsqlite3-sys`, and the `cc` crate compiles it at the profile's opt-level —# so every debug and test build ran an UNOPTIMISED SQLite. The workspace's tests# open, migrate and query real files: the store, every MCP tool test, every# server route. On 28 Sep 2026 the Linux `rust` job spent 10–11 of its ~19# minutes RUNNING tests (5,116–5,609 test-seconds on 8 threads), the largest# item in push-to-green's slowest job.## Measured on the Mac mini, same tree, same 8 test threads, `cotton-store` +# `cotton-tools` (2,042 tests), two passes each:## libsqlite3-sys at opt-level 0 806 s, 788 s# libsqlite3-sys at opt-level 3 530 s, 467 s — 37% less wall time## The same trade as scrypt's: ONE leaf crate, C code with nothing of this# workspace inside it, whose bytes on disk do not change with the flag. What it# costs is one optimised compile of the amalgamation in a cold target — the# slots and sccache keep it after that. Guard: `scripts/__tests__/cargo-debug-opt.test.ts`.[profile.dev.package.libsqlite3-sys]opt-level = 3