# Octropy > Octropy is a Rust library compiled into a desktop app. It connects the app's users' computers to > each other directly and gives the app sessions, streams, datagrams, files, identity, invites and > delivery while someone is away, with no backend for the developer to run for sync and delivery. > The app talks to it through the Octropy API (wire name `octropy-local/1`) over an in-memory pipe. Status: preview. Octropy runs the Neptunion app every day. Opening it to other developers is being built: the library, the Octropy API, the C interface, the Electron path and the update check exist but are NOT released, and how the code is distributed (registry, git, access on request) is not decided. Human-readable page: /docs on the site that serves this file (same content). If you cannot find the Octropy crate or the Electron template, stop and tell the person you are working for. Do not guess install steps, invent a package name, or write a stand-in. ## Rules agents get wrong 1. Compile Octropy from source as part of the app's build. There is no prebuilt binary, no separate program to ship or start, and no npm package from Octropy. 2. Do not turn off contribution or encryption. They are not settings. An app can lower the user's contribution limits to Octropy's minimums, not switch giving back off. 3. Call `octropy_node::no_core_dumps()` once at start, before any key is read (Rust apps). Octropy runs in the app's process, so a core file would hold the device keys. 4. Give Octropy one data folder per user per app, in the user's own application data. Never a temp folder, never shared between users, never deleted on app update: deleting it gives the computer a new identity. 5. Keep the returned node alive as long as the network should run. A second copy of the app on the same folder gets no node (its events say why once); do not try to force it. 6. Octropy never updates itself. A newer Octropy ships in the app's next release. Do not delete the build's floor check; a build below the floor fails on purpose. Use `OCTROPY_FLOOR_OFFLINE=1` only for a deliberately offline build (it is stamped as such). 7. Ignore unknown events and unknown fields; they are added over time within `octropy-local/1`. 8. Octropy never reads a session frame after the handshake: what a frame means is the app's. 9. Never put a check for a paid service in the app or the library. Paid services are decided only on Octropy's own always-on members. 10. Electron: build `octropy.node` before packaging, keep it out of asar, and replace the file when rebuilding instead of writing over it (macOS kills a process whose signed library changed in place). ## Rust and Tauri ```rust octropy_node::no_core_dumps(); let config = octropy_node::Config { services: octropy_node::Services::embedded(), ..octropy_node::Config::new(support.join("Octropy")) }; let (node, client, events) = octropy_client::Node::embedded(config, setup).await; // node is None when another copy holds this data folder; events says why once. // node.stop() ends every session and releases the folder within two seconds. ``` Depend on `octropy-client` (feature `in-process`) and `octropy-node`. Logs go through `tracing`. ## Electron A small Rust project (Octropy's template, `octropy-electron`) compiled by Cargo with napi-rs into a Node-API module, `octropy.node`, loaded by the main process. One build per platform and architecture. Signed with the app. ```js const { Octropy } = require("./octropy-electron/octropy.js") const node = new Octropy({ data: path.join(app.getPath("userData"), "octropy"), appId: "com.you.app" }) const identity = Octropy.identity() // persist it: it is this computer await node.attach({ id: "com.you.app", version: app.getVersion(), build: 1 }, identity, "My Mac") node.on("session.in", (s) => { /* s.lane */ }) node.on("frame", ({ lane, kind, body }) => { /* bytes */ }) // node.request({ t: "session.open", ... }), node.frame(lane, kind, bytes) ``` Forge: `packagerConfig.asar.unpack: "**/octropy.node"` and the template's `generateAssets` hook. electron-builder: the template's `beforeBuild` hook and `asarUnpack: ["**/octropy.node"]`. ## Other languages C interface `octropy.h`: `octropy_open`, `octropy_write`, `octropy_read`, `octropy_close`, `octropy_token`, `octropy_identity`, `octropy_version`. Swift and Kotlin through it: later. Bindings wrap the Octropy API; none has a capability the API lacks. ## The Octropy API (`octropy-local/1`) Two in-memory pipes, 64 KiB each way: `ctl` (control, session frames, stream data) and `rt` (datagrams and call streams). Framing: `u32be length`, `u8 type` (1 ctl, 2 frame, 3 bytes, 4 dgram, 5 credit, 6 end), `u32be lane` (0 is control), payload (ctl: one JSON object; frame: wire kind and body ≤ 2 MiB; dgram ≤ 65 535 bytes). The Rust client, C interface and Electron module frame and grant credit themselves. Control messages are JSON with `t`; requests carry `id`, answers echo it. Attach: the app sends `hello` with the API range it speaks (`api: [min, max]`); Octropy answers `welcome` or `refused {why:"api"}`. Additive within a version. App to Octropy: attach (`hello`, `keys`, `me`, `friends.set`, `friends.patch`, `doors.set`, `settings`, `alpns.claim`, `hints.set`, `app.state`); sessions (`session.open`, `session.cancel`, `session.close`, `session.export`, `standing.answer`); connections (`conn.open`, `conn.close`, `conn.measure`, `stream.open`, `stream.end`); finding (`look`, `rediscover`, `probe`, `netcheck`, `online.check`); holding (`hold.put`, `hold.get`, `hold.drop`, `hold.keep`, `hold.state`, `hold.who`); paid (`paid.ask`, coming); giving back (`contribution.set`); housekeeping (`update.check`, `ping`, `quit`). Octropy to app: `welcome`, `refused`, `ok`, `error`, `unknown`, `pong`; `standing.ask`, `standing.in`, `peer.noted`, `session.in`, `session.opened`, `session.failed`, `session.exported`; `conn.in`, `conn.opened`, `conn.failed`, `conn.closed`, `conn.measured`, `stream.in`, `stream.opened`; `seen`, `gone`, `greeted`, `present`, `online`, `reached`, `net`, `status`; `floor`, `update.ready`; `hold.done`, `hold.got`, `hold.holders`, `hold.gone`, `hold.held`; `paid.answer` (coming); `contribution`. ## Concepts - Social cloud: members (the running copies of Octropy) do for each other what a cloud provider does. Holding: sealed bundles for someone away wait with up to four members (own devices and friends first) for up to two weeks; delivery, not backup. Carrying: a member passes on sealed bytes when two computers cannot reach each other. Finding: Octropy's own table of who is where, friends first, started from an Octropy always-on member. Helpers cannot read what they hold. - Ways to a friend: same network, nearby (two Macs over Wi-Fi, no router), direct through both routers, relayed by a public relay (sealed bytes), carried by another member. The app never chooses. - Giving back: the network contribution panel is data. `contribution.set {disk?, traffic?, pauseOnBattery, pauseOnMetered}`; `contribution` returns the limits, minimums, what was carried and held, and a plain `line` for the panel. A computer never takes more disk than it lends. The app must show the panel. Minimum contribution: not set yet. - One app per computer does the network's work (carrying, holding for strangers, finding) for all Octropy apps on that computer; the others do only their own sessions. No keys or app identities cross between them. - Updates: the build checks Octropy's signed client floor (fails below it, warns below latest; CI: `octropy check --lock Cargo.lock`). The network minimum: after a published date, members refuse older versions; before it, the app gets a `floor` event to prompt an update. - Keys: self-custody by default; password-sealed key backup and full custody are coming. Full custody means the developer can read users' content. Octropy has no mandatory accounts. - Paid services (coming): backups first (kept for good, three copies), later business vaults, phone access, compute. Performed on Octropy's always-on members after checking payment. Sold by the developer through their own Stripe account (direct charges); the developer is the merchant of record; Octropy takes a fixed fee per paid service. Margin = price − Octropy's fee − Stripe's fees. No prices are published. - Phones cannot take part in the social cloud; phone access is a paid service through Octropy's always-on members. No phone library is promised. - Parts: everything is compiled in for now; a part the app never calls does nothing. An app may connect people directly without the social cloud (then it neither gives back nor gets holding or carrying), or use Octropy only for paid services. - Advanced features (web-facing, need the developer's domain; browser links): later. ## Limits Nothing that needs a server-side view across all users (global search, proactive moderation, cross-user analytics). Desktop only: macOS, Windows, Linux. The Electron module and C interface have run on macOS only so far. ## Licence Published with the first release.