Architecture — MacLustr Distributed Storage Fabric, Mobile Extension
1. What was found in MacLustr (audit of 2026-12-01)
| Subject | Finding | Consequence |
|---|---|---|
| Node registration | Macs and servers are registered by mld (SSH, markers) and by the Command Center agents (mcc-agent, signed HTTPS requests). An iPhone can run neither. |
Mobile nodes get their own enrolment: pairing code + device key (§3). |
| Earlier mobile work | maclustr-mobile (M4M64a:9320) makes iPhones pull compute jobs with a shared token. The Command Center brief forbids reusing it, and a shared token is not an identity. |
Not reused. Not touched. |
| Dashboard | clustr.spboucher.ai = MacLustr Command Center (Go control-api + Next.js, M4M64c). Passkey sessions, roles, audit. |
The "Mobile Storage Nodes" section is added there; it reads the coordinator through its admin API. |
| Storage of Macs and NAS | No distributed storage engine exists in MacLustr: each app keeps its data on its node's SSD, backups are per-app rsync. No NAS is attached to the cluster (the Ugreen unit is not connected). | The stable store of this fabric is new and lives on the coordinator's node. Nothing existing was replaced. |
| Tunnel, domains, certificates | Public exposure = DNS A → 51.161.112.61 (BHS64) + Caddy route posted by mld deploy + WireGuard to the node. Certificates by Caddy (ACME). |
storage.spboucher.ai uses exactly this. No new mechanism. |
| Local Network Privacy (macOS 27) | A third-party binary under PM2 cannot open connections to LAN peers; listening works, Apple binaries work. | The coordinator only listens; Bonjour is announced by Apple's dns-sd. The dashboard reaches the coordinator through its public URL. |
2. Components
MacLustr cluster
│
Storage Coordinator ── stable fragment store (HOT, SSD of m4mn) ── catalog (SQLite)
│ ▲ every fragment always has its copy here
Mobile Storage Gateway (MSP/1: storage.spboucher.ai + LAN listener :8871)
│ connections opened by the devices only
├── iPhone storage node (mobile_opportunistic)
├── iPhone storage node
└── iPad storage node| Component | Where | Code |
|---|---|---|
| Storage coordinator + mobile gateway | mld app maclustr-storage, node m4mn, PM2 storage-coordinator (8870 gateway, 8871 LAN) and storage-backup |
server/ — Node ≥ 24, TypeScript run natively, no dependency |
| iOS app | App Store Connect 6841553137, bundle ai.spboucher.maclustr.storage |
MacLustrStorageNode/ — Swift, SwiftUI, no third-party code |
| Dashboard section | Command Center, clustr.spboucher.ai |
repository maclustr-command-center |
| CLI | server/bin/mlstore.ts |
same admin API as the dashboard |
3. Storage classes
| Class | Hardware | Role in this fabric |
|---|---|---|
| HOT | Mac Studio / Mac mini | stable store: authoritative copy of every fragment (today: m4mn) |
| WARM | NAS / servers | not attached yet; a second stable replica belongs here (see §8) |
OPPORTUNISTIC (mobile_opportunistic) |
iPhone / iPad | redundant copies only; may vanish at any time |
Rule enforced by the coordinator: no fragment needed to rebuild an object ever exists only on an iOS device. Concretely
(server/src/coordinator.ts): objects are written to the stable store before anything is offered to a device; the scheduler
only places fragments whose stable copy is ok; a drain deletes a fragment from a device only after re-checking the stable
copy, and pulls the fragment back first if that copy is missing; the overview exposes fragments_only_on_mobile, which the
tests require to be 0.
The mobile copies are still useful, not decorative: when a stable copy is lost or corrupt (found on read or by the scrub), the coordinator restores it from a mobile node that holds the fragment. This was exercised on the live system (see TEST-REPORT.md).
4. Data path
- Ingest (
PUT /admin/v1/objects): the stream is cut into fragments ofMSC_FRAGMENT_MIB(8 MiB), each chunk is encrypted with AES-256-GCM, the fragment (ciphertext ‖ 16-byte tag) is written atomically to the stable store under its SHA-256, then the catalog transaction commits. - Encryption happens on the cluster. Key and nonce derive from the cluster master key and the SHA-256 of the plaintext chunk (HMAC-SHA256). Identical chunks therefore give identical fragments — deduplication — while nothing can be derived or confirmed without the master key; each (key, nonce) pair encrypts exactly one plaintext. Devices only ever see ciphertext and never receive a key.
- Placement (every 3 s): for each online node that accepts writes, fragments with fewer than
MSC_MOBILE_REPLICAS(2) mobile copies are assigned, fewest copies first, withinmin(quota − committed, space the device reports writable), at most 12 queued per node. Offline nodes keep their placements: opportunistic nodes sleep constantly, and re-replicating each time would only churn flash and bandwidth. - Verification: a possession proof at the end of each store, then every 6 h per fragment; the device also scrubs its own fragments (full re-hash) and reports corruption; the coordinator scrubs the stable store continuously.
- Read (
GET …/content): from the stable store, every fragment checked against its id, the whole object against its digest. A missing stable fragment gives503and schedules its recovery from a mobile node.
5. iOS app
MacLustrStorageNode/
├── App/ entry point, root view, theme
├── Core/
│ ├── Storage/ MacLustr Mobile Storage Engine: FragmentStore (actor), FragmentIndex (SQLite), CapacityMonitor
│ ├── Networking/ MSPClient (signed requests, pinning), TransferService (URLSessions), LANDiscovery (Bonjour)
│ ├── Security/ DeviceIdentity (Secure Enclave key, rotation), Keychain
│ ├── Synchronization/ NodeEngine (actor): policy, heartbeat, work, reconciliation, drain
│ ├── Background/ BackgroundScheduler (BGAppRefreshTask, BGProcessingTask)
│ └── Diagnostics/ DeviceConditions (network, power, thermal), Benchmark
├── Features/ Onboarding, Dashboard (+ station mode), Allocation, Activity, Settings
├── Models/ value types
└── Services/ NodeController (bridge engine → SwiftUI)
MacLustrStorageNodeTests/ unit tests of the engine and protocol helpersMacLustr Mobile Storage Engine
- Fragments live in
Application Support/MobileStorageEngine/fragments/<aa>/<sha256>— never in Caches (purgeable), excluded from iCloud and Finder backups (isExcludedFromBackup), protection class "until first unlock" so that work continues while the screen is locked. - Commit is the only way in: size check → streamed SHA-256 must equal the id →
fsync→ journal row → atomic rename → index row and journal removal in one transaction. A fragment already held is not written twice. - Recovery at every launch: interrupted operations from the journal are finished or undone; index rows without a file are dropped; files without a row are adopted if their content matches their name, removed otherwise; partial downloads nobody owns are cleared. It is idempotent.
- Quota:
writable = min(quota − used, free − reserve), reserve = larger of 20 GB and 10 % of the device (configurable, never under 5 GB). Nothing is pre-allocated. When free space reaches the reserve the node reportsaccepting: false(low_space) and refuses store tasks; an arriving fragment that would cut into the reserve is discarded. - Hashing is streamed 1 MiB at a time: memory does not grow with the fragment size.
Node engine
One actor owns the state. Loops (foreground): heartbeat, long-poll for work, rate meter, maintenance (scrub, daily inventory, key rotation). The policy function decides from live conditions whether the node may transfer at all and whether it accepts new fragments, and how many transfers run in parallel (4 in station mode on power, 3 normally, 2 when warm or in the background, 1 on cellular or when hot). Every pause has a reason shown to the user and sent to the cluster.
6. Security model (summary — see SECURITY.md)
Zero trust in both directions: the coordinator authenticates each request by the device's signature; the device accepts only four operations and verifies every byte it stores; the LAN endpoint is trusted only through a pinned certificate; a device holds ciphertext without keys; revocation is immediate.
7. Erasure coding (Reed-Solomon): studied, not adopted in 1.0
| Replication (current) | Reed-Solomon k+m across mobile nodes | |
|---|---|---|
| Purpose in this fabric | extra copies of fragments that already have a stable copy | same: the stable copy stays mandatory by rule |
| Mobile space for one extra loss tolerance | 1× per copy | m/k × (e.g. 0.5× for 4+2) |
| Repair of a stable fragment | one transfer from one device | k transfers from k distinct devices, all online at the same time |
| Device-side work | none beyond hashing | none (coding would stay on the cluster) |
| Coordinator complexity | low | stripes, generations, partial-stripe repair, GF(256) codec to write and test |
With mobile nodes the binding constraint is not space but simultaneous availability: a k-of-n read needs k devices reachable at once, and iPhones are reachable a fraction of the time. With the fleet in view (a handful of devices), the probability of finding k of them awake together is low exactly when a repair is needed, whereas a plain replica needs one. Reed-Solomon becomes worth its complexity when (a) there are enough nodes for n ≥ 6 distinct devices per stripe, and (b) measured availability is high (dedicated, plugged-in devices in station mode), or when WARM storage joins and stripes can span NAS + mobile. The catalog already separates objects, fragments and placements, so stripes can be added as a new placement policy without changing MSP/1 or the app: a parity fragment is just another opaque fragment.
8. Known limits of 1.0
- One stable copy. The stable store and the catalog are on one node (m4mn). The catalog is backed up daily on the same
disk (
storage-backup). Losing that node's disk loses the catalog and the master key, and with them the ability to read the fragments the phones hold. A second stable replica (another Mac, or the NAS once attached) and an off-node copy of~/.config/maclustr-storageare the first things to add;server/scripts/backup.shis the hook. - No client of the fabric yet. Objects enter through the admin API /
mlstore put. No MacLustr app writes to it. - No silent push. The app is not woken by the cluster; background work depends on iOS scheduling (IOS-LIMITS.md).
- The dashboard's node health is derived from heartbeats; there is no alerting rule on it yet.