docs: tighten v1 scope + add flashy README 📦✨
Folded post-audit verdict into the spec: - cut blocking-prompt conflict mode + the manager/member role/grant/clamp system (-> single server-enforced per-(device,share) read-only bit) - collapsed 4 conflict-notify modes to 1 (copies + status badge + on-conflict hook + `devbox conflicts` list); interactive resolver -> v2 - kept WS(events)+HTTP(blobs) split (not pure-WS); bash default + .ps1->pwsh - content-addressed manifests (no full BLOB per snapshot) - promoted into v1: default-on secret guard, bandwidth cap, hub /metrics - new M6.5 `devbox deploy <share> <snapshot>`; v2 backlog section Add README.md with Mermaid diagrams, comparison grids, emoji, the works.
This commit is contained in:
parent
a4f72c3413
commit
6e8dd6f973
2 changed files with 759 additions and 261 deletions
520
README.md
Normal file
520
README.md
Normal file
|
|
@ -0,0 +1,520 @@
|
|||
<!-- ════════════════════════════════════════════════════════════════════ -->
|
||||
<div align="center">
|
||||
|
||||
<img src="https://readme-typing-svg.demolab.com/?font=Fira+Code&size=40&duration=3000&pause=800&color=4F9CF9¢er=true&vCenter=true&width=720&height=90&lines=%F0%9F%93%A6+devbox;Dropbox+for+Developers;Sync+without+the+Git+ceremony" alt="devbox" />
|
||||
|
||||
### 📦 **Continuous file sync for developers — like Dropbox, but it respects your `.devignore`, refuses to leak secrets, runs your hooks, and keeps Git-like history.** 📦
|
||||
|
||||
<br/>
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
</div>
|
||||
|
||||
<!-- ════════════════════════════════════════════════════════════════════ -->
|
||||
|
||||
```
|
||||
╔═══════════════════════════════════════════════════════════╗
|
||||
║ ┌─┐ ┌─┐ ┬ ┬ ┌┐ ┌─┐ ┬ ┬ ║
|
||||
║ ││─┤ ├┤ │ │ ├┴┐│ │ │┴┤ sync your dev tree, ║
|
||||
║ ┴─┘─┘└─┘ └──┘ └─┘└─┘ ┴ ┴ skip the junk, keep history ║
|
||||
╚═══════════════════════════════════════════════════════════╝
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> 🚧 **devbox is in the design phase.** The spec is complete
|
||||
> ([`docs/superpowers/specs`](docs/superpowers/specs/2026-06-22-devbox-design.md)) and
|
||||
> implementation is just beginning. **Everything below describes the v1 design — it is not yet
|
||||
> shippable.** Star/watch and follow along. ⭐
|
||||
|
||||
---
|
||||
|
||||
## 📑 Table of Contents
|
||||
|
||||
| | | |
|
||||
|---|---|---|
|
||||
| 🤔 [Why devbox?](#-why-devbox) | 🧠 [Core Concepts](#-core-concepts) | 🏗️ [Architecture](#%EF%B8%8F-architecture) |
|
||||
| 🔄 [How Sync Works](#-how-sync-works) | 💥 [Conflicts](#-conflicts-never-lose-a-byte) | 🚀 [Quick Start](#-quick-start) |
|
||||
| 🧰 [CLI Reference](#-cli-reference) | 🪝 [Hooks](#-hooks) | 🙈 [.devignore & Secrets](#-devignore--secret-guard) |
|
||||
| 🕰️ [Versioning & Deploy](#%EF%B8%8F-versioning--deploy) | 🖥️ [Cross-Platform](#%EF%B8%8F-cross-platform) | 🗺️ [Roadmap](#%EF%B8%8F-roadmap) |
|
||||
| ⚖️ [License & Open-Core](#%EF%B8%8F-license--open-core) | 🙌 [Contributing](#-contributing) | |
|
||||
|
||||
---
|
||||
|
||||
## 🤔 Why devbox?
|
||||
|
||||
You've got a MacBook, a 40-node Pi cluster, and a TrueNAS box. You want your **active working
|
||||
tree** mirrored across them — *right now*, automatically — without committing half-done work.
|
||||
|
||||
Your options today all hurt:
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Tool</th><th>The pain 😖</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>☁️ <b>Dropbox / iCloud</b></td>
|
||||
<td>Syncs <i>everything</i> blindly — chokes on <code>node_modules</code>, happily uploads your <code>.env</code>, thrashes on build artifacts.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>🐙 <b>Git</b></td>
|
||||
<td>Manual. Commit-based. Not built to live-mirror an in-progress working tree. Branching ≠ syncing.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>📁 <b>rsync / scp</b></td>
|
||||
<td>One-shot, one-direction, no history, no hooks, no conflict safety. You babysit it.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>🔁 <b>Syncthing</b></td>
|
||||
<td>Great P2P sync — but no <code>.devignore</code> dev-ergonomics, no lifecycle hooks, no snapshot/deploy story.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### ✨ devbox is the missing layer
|
||||
|
||||
<div align="center">
|
||||
|
||||
| 🎯 | Feature |
|
||||
|:---:|:---|
|
||||
| 🔄 | **Continuous bidirectional sync** across all your machines |
|
||||
| 🙈 | **`.devignore`** (gitignore syntax) — skip `node_modules`, `dist`, the junk |
|
||||
| 🔐 | **Default-on secret guard** — *hard-refuses* to upload `.env`, keys, secrets |
|
||||
| 🪝 | **Lifecycle hooks** — `pnpm install` / restart a container when files land |
|
||||
| 🕰️ | **Git-like snapshots** per share — roll back any file, any time |
|
||||
| 🎚️ | **Selective mounts** — cherry-pick a share, or *just one sub-path*, per machine |
|
||||
| 💥 | **Conflict-safe** — never blocks, never asks, **never loses a byte** |
|
||||
| 🏠 | **Self-hostable** — one Go binary on your Pi/TrueNAS, no SaaS required |
|
||||
| 🌍 | **Cross-platform** — Linux · macOS · Windows |
|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## 🧠 Core Concepts
|
||||
|
||||
```mermaid
|
||||
mindmap
|
||||
root((📦 devbox))
|
||||
🛰️ Hub
|
||||
publishes shares
|
||||
stores chunks + manifests CAS
|
||||
brokers change events
|
||||
one owner · many devices
|
||||
💻 Device
|
||||
Ed25519 identity
|
||||
joins with a token
|
||||
runs one daemon
|
||||
📂 Share
|
||||
named tree projects/ repos/ services/
|
||||
unit of snapshot history
|
||||
🔗 Mount
|
||||
share + subpath to local path
|
||||
read-write or read-only
|
||||
📸 Snapshot
|
||||
immutable BLAKE3 manifest
|
||||
per share history
|
||||
```
|
||||
|
||||
| Term | What it is |
|
||||
|---|---|
|
||||
| 🛰️ **Hub** | The server. Publishes shares, stores content-addressed chunks + manifests, brokers events. One owner, many devices. Self-hosted single binary. |
|
||||
| 💻 **Device** | A machine with an Ed25519 identity, joined to a hub. Runs one daemon (`devboxd`). |
|
||||
| 📂 **Share** | A named top-level tree on the hub (`projects`, `repos`, `services`). The unit of permission & history. |
|
||||
| 🔗 **Mount** | A device-side binding: `share[/subpath] → localpath`, read-write or read-only. One daemon watches many. |
|
||||
| 📸 **Snapshot** | An immutable, per-share manifest version (id = BLAKE3 of the manifest). |
|
||||
|
||||
---
|
||||
|
||||
## 🏗️ Architecture
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph LAP["💻 MacBook"]
|
||||
D1["devboxd 🛡️"]
|
||||
M1["📂 projects/"]
|
||||
M2["📂 repos/"]
|
||||
end
|
||||
|
||||
subgraph HUB["🛰️ Hub · Pi / TrueNAS"]
|
||||
WS{{"🔌 WebSocket\nchange events"}}
|
||||
HTTP{{"🌐 HTTP\nblob GET/PUT"}}
|
||||
CAS[("🧊 CAS\nchunks + manifests\nBLAKE3")]
|
||||
DB[("🗄️ SQLite WAL\nshares · snapshots\ndevices · tokens")]
|
||||
MET["📊 /metrics + status"]
|
||||
end
|
||||
|
||||
subgraph PI["🍓 pi-07"]
|
||||
D2["devboxd 🛡️"]
|
||||
M3["📂 projects/p22/backend\n(read-only → /var/www)"]
|
||||
end
|
||||
|
||||
M1 & M2 -->|"events"| WS
|
||||
M1 & M2 -->|"blobs"| HTTP
|
||||
WS --> CAS
|
||||
HTTP --> CAS
|
||||
CAS --- DB
|
||||
WS -->|"events"| D2
|
||||
HTTP -->|"blobs"| D2
|
||||
D2 --> M3
|
||||
|
||||
classDef hub fill:#0d1117,stroke:#4F9CF9,stroke-width:2px,color:#fff;
|
||||
class HUB,WS,HTTP,CAS,DB,MET hub;
|
||||
```
|
||||
|
||||
> 💡 **Why two channels?** WebSocket for live events (tiny, ordered) + **stateless HTTP for
|
||||
> blobs** (`GET /blob/<hash>` → range/resume/caching for free). Same TLS endpoint, same token.
|
||||
> Pure-WebSocket would force us to reinvent resumable transfer over a socket — *more* code.
|
||||
|
||||
---
|
||||
|
||||
## 🔄 How Sync Works
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
autonumber
|
||||
participant FS as 📁 Filesystem
|
||||
participant D as 🛡️ devboxd
|
||||
participant H as 🛰️ Hub
|
||||
participant P as 🍓 Peer
|
||||
|
||||
FS->>D: ✏️ file changed (fsnotify, debounced ~300ms)
|
||||
D->>D: 🙈 .devignore + 🔐 secret-guard filter
|
||||
D->>D: 🧩 FastCDC chunk → BLAKE3 → manifest diff
|
||||
D->>D: 🪝 pre-push hook (can veto 🛑)
|
||||
D->>H: ⬆️ upload missing chunks (HTTP, bw-capped)
|
||||
H->>H: 📸 append snapshot, advance share HEAD
|
||||
H-->>D: ✅ ack
|
||||
D->>D: 🪝 post-push hook
|
||||
H->>P: 🔔 change event (WebSocket)
|
||||
P->>P: 🪝 pre-pull hook (can veto 🛑)
|
||||
P->>H: ⬇️ fetch missing chunks (HTTP)
|
||||
P->>P: 🧱 reassemble → ⚛️ atomic rename into place
|
||||
P->>P: 🪝 post-pull hook (pnpm install / restart 🚀)
|
||||
```
|
||||
|
||||
A **read-only** mount skips steps 1–8 (it never pushes) but still receives and applies inbound
|
||||
changes. 🔒
|
||||
|
||||
---
|
||||
|
||||
## 💥 Conflicts: Never Lose a Byte
|
||||
|
||||
devbox is **Dropbox-easy** (never nags you mid-work) **and** data-loss-proof. Here's the magic:
|
||||
the hub keeps a **linear HEAD per share**, and every push declares the snapshot it was based on.
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
START([📤 push arrives]) --> Q{parent == HEAD?}
|
||||
Q -->|✅ yes| FF["⏩ fast-forward\nadvance HEAD"] --> DONE([🎉 done])
|
||||
Q -->|❌ no| THREE["🔱 per-file 3-way\nvs common ancestor"]
|
||||
THREE --> ONLY{changed by\nonly the pusher?}
|
||||
ONLY -->|yes| CLEAN["✨ applies cleanly"] --> DONE
|
||||
ONLY -->|both sides| CONF["💥 CONFLICT"]
|
||||
CONF --> KEEP["👑 first-to-land stays canonical"]
|
||||
CONF --> COPY["📝 loser saved as\nfoo.conflict-laptop-1719.go"]
|
||||
CONF --> HOOK["🔔 on-conflict hook fires"]
|
||||
KEEP & COPY & HOOK --> SAFE([🛟 zero data lost])
|
||||
|
||||
style CONF fill:#5a1e1e,stroke:#ff6b6b,color:#fff
|
||||
style SAFE fill:#1e5a2e,stroke:#51cf66,color:#fff
|
||||
style DONE fill:#1e5a2e,stroke:#51cf66,color:#fff
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>📖 <b>The classic "laptop was offline" scenario — click to expand</b></summary>
|
||||
|
||||
<br/>
|
||||
|
||||
Both machines synced at snapshot `S3`, both have `foo.go` v1:
|
||||
|
||||
1. 🔌 **Laptop goes offline**, edits `foo.go` → **v2-laptop** (queued, parent still `S3`).
|
||||
2. 🍓 **Pi (online)** edits the same `foo.go` → **v2-pi**, pushes. Hub HEAD `S3 → S4`. Pi's wins canonical.
|
||||
3. 🔌 **Laptop reconnects**, pushes with `parent=S3` — but HEAD is `S4`. `parent ≠ HEAD` → conflict path.
|
||||
4. 🔱 Both changed `foo.go` since `S3` → real conflict.
|
||||
5. 🛟 **Result, nothing destroyed:** both machines end up with
|
||||
`foo.go` = **v2-pi** (canonical) **and** `foo.conflict-laptop-1719.go` = **v2-laptop** beside it.
|
||||
|
||||
The offline edit is **never lost** — it just lands as a clearly-named sibling. 🎯
|
||||
|
||||
</details>
|
||||
|
||||
**Conflict rules at a glance:**
|
||||
|
||||
| Situation | Outcome |
|
||||
|---|---|
|
||||
| 🤝 Both edit same file | First-to-land canonical; loser → `.conflict-<host>-<ts>` copy |
|
||||
| 🗑️ One deletes, one edits | **Edit always wins** — a delete has no bytes to lose |
|
||||
| 🔤 Rename | Free — old-gone + new-added; content-addressed = zero re-transfer |
|
||||
| 🔒 Read-only mount about to clobber a local edit | Local stashed as `.conflict-local-<ts>` first |
|
||||
| 👀 You find out via | `devbox status` badge · `on-conflict` hook · `devbox conflicts` list |
|
||||
|
||||
> 🚫 **No blocking prompts.** A headless daemon can't prompt you, and nagging would break the
|
||||
> whole "Dropbox-easy" promise. You get told; you choose when to look.
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
> 🚧 *Design preview — these commands describe v1, not a shipping binary yet.*
|
||||
|
||||
```bash
|
||||
# 🛰️ On your hub (Pi / TrueNAS)
|
||||
devbox-hub serve --config /etc/devbox-hub.toml
|
||||
devbox-hub token # prints a join token → J0IN-7QF2-K9XR
|
||||
|
||||
# 💻 On each device
|
||||
devbox join hub.shoemoney.ai J0IN-7QF2-K9XR # enroll this machine
|
||||
devbox publish ~/Projects projects # create a share from a folder
|
||||
devbox start # run the daemon
|
||||
|
||||
# 🍓 On a Pi node — mount just one backend, read-only, somewhere else
|
||||
devbox join hub.shoemoney.ai J0IN-7QF2-K9XR
|
||||
devbox -r projects/p22/backend /var/www/p22/backend
|
||||
devbox start
|
||||
```
|
||||
|
||||
That's it. ✨ Edit on your laptop → it lands on the Pi in near-real-time, `node_modules` stays
|
||||
home, your `.env` *never leaves the building*, and `post-pull` can `pnpm install` + restart your
|
||||
container automatically. 🪄
|
||||
|
||||
---
|
||||
|
||||
## 🧰 CLI Reference
|
||||
|
||||
<details open>
|
||||
<summary>💻 <b>Device commands</b></summary>
|
||||
|
||||
| Command | What it does |
|
||||
|---|---|
|
||||
| `devbox join <hub> <token>` | 🎟️ Enroll this device against a hub |
|
||||
| `devbox -rw <share>[/sub] [path]` | 🔗 Mount a share/sub-path **read-write** (default `./<name>`) |
|
||||
| `devbox -r <share>[/sub] [path]` | 🔒 Mount **read-only** |
|
||||
| `devbox publish <dir> <name>` | 📂 Create a share from a local folder |
|
||||
| `devbox unmount <share>` | ⏏️ Stop syncing a mount (files stay on disk) |
|
||||
| `devbox start` / `stop` | ▶️⏹️ Run / stop the daemon |
|
||||
| `devbox status` | 📊 Shares, mounts, peers, conflicts, blocked secrets |
|
||||
| `devbox pause` / `resume` | ⏸️▶️ Halt sync without unmounting |
|
||||
| `devbox log` | 🕰️ Snapshot history |
|
||||
| `devbox restore <snap> [path]` | ↩️ Roll back a file or a whole share |
|
||||
| `devbox deploy <share> <snap>` | 🚢 Pin a read-only mount to a snapshot *(v1.5)* |
|
||||
| `devbox conflicts` | 💥 List conflict copies |
|
||||
| `devbox ignore <pattern>` | 🙈 Append to `.devignore` + rescan |
|
||||
| `devbox hook edit <event>` | 🪝 Open a hook in `$EDITOR` |
|
||||
| `devbox peers` | 🌐 Linked machines, online/offline, last seen |
|
||||
| `devbox doctor` | 🩺 Diagnose watcher limits, perms, hook interpreter, connectivity |
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>🛰️ <b>Hub commands</b> (run on the hub host)</summary>
|
||||
|
||||
| Command | What it does |
|
||||
|---|---|
|
||||
| `devbox-hub serve --config <file>` | 🚀 Start the hub |
|
||||
| `devbox-hub token` | 🎟️ Mint / rotate the join token |
|
||||
| `devbox-hub device list` / `revoke <id>` | 📋❌ List / revoke devices |
|
||||
| `devbox-hub readonly <device> <share>` | 🔒 Mark a device read-only on a share |
|
||||
| `devbox-hub gc` | 🧹 Garbage-collect unreferenced chunks |
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
|
||||
## 🪝 Hooks
|
||||
|
||||
Drop executable scripts in `<mount>/.devbox/hooks/`, named after the event. **bash everywhere**
|
||||
(a `.ps1` hook auto-runs via `pwsh` on Windows 🪟). `pre-*` non-zero exit **aborts** the step.
|
||||
60s timeout — a hung hook is killed, never wedges the loop. ⏱️
|
||||
|
||||
| Hook | Fires | Abort? | Typical use |
|
||||
|---|---|:---:|---|
|
||||
| `pre-push` | before upload | ✅ | 🧹 lint/format, secret scan |
|
||||
| `post-push` | after upload | ❌ | 📣 notify, log, tag a snapshot |
|
||||
| `pre-pull` | before apply | ✅ | 🛑 stop a container / dev server |
|
||||
| `post-pull` | after apply | ❌ | 📦 `pnpm install`, migrate, restart |
|
||||
| `on-conflict` | conflict copy made | ❌ | 🔔 open a diff, ping you, log |
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
# .devbox/hooks/post-pull — reinstall deps + restart only when needed
|
||||
if grep -qE 'package\.json|pnpm-lock\.yaml' "$DEVBOX_CHANGED_FILES"; then
|
||||
pnpm install --frozen-lockfile
|
||||
fi
|
||||
docker compose restart app # 🚀
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>🌱 <b>Injected environment variables</b></summary>
|
||||
|
||||
```bash
|
||||
DEVBOX_EVENT=post-pull
|
||||
DEVBOX_MOUNT=/srv/project
|
||||
DEVBOX_SHARE=projects
|
||||
DEVBOX_HOST=pi-node-07
|
||||
DEVBOX_CHANGED_FILES=/tmp/devbox-changes.txt # newline-delimited
|
||||
DEVBOX_SNAPSHOT=ab12cd34
|
||||
DEVBOX_REMOTE=hub.shoemoney.ai
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
|
||||
## 🙈 .devignore & Secret Guard
|
||||
|
||||
### 🙈 `.devignore` — gitignore syntax, shared at the share root
|
||||
|
||||
```gitignore
|
||||
node_modules/ # 📦 the usual suspects
|
||||
dist/ build/ .next/ target/
|
||||
*.log *.tmp .DS_Store
|
||||
!.env.example # ❗ negate to force-include
|
||||
```
|
||||
|
||||
Matched paths are **invisible to sync in both directions**. Change it → rescan; newly-ignored
|
||||
files are **left on disk** (never deleted), they just stop syncing.
|
||||
|
||||
### 🔐 Secret Guard — *always on, independent of `.devignore`*
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Your pitch is "won't leak your `.env`" — so devbox **enforces it**. A built-in deny-list runs
|
||||
> in the push path and **hard-refuses to upload** matched files *even if `.devignore` is
|
||||
> misconfigured.* Belt **and** suspenders. 🩲
|
||||
|
||||
Default-blocked: `.env` · `.env.*` (except `.env.example`) · `*.pem` · `*.key` · `id_rsa*` ·
|
||||
`*.p12` · `*.pfx` · `secrets/` · `*.kdbx` · common cloud-cred files. Blocked files show up in
|
||||
`devbox status`. Add your own via `[secrets].extra_patterns` in `config.toml`.
|
||||
|
||||
---
|
||||
|
||||
## 🕰️ Versioning & Deploy
|
||||
|
||||
```mermaid
|
||||
gitGraph
|
||||
commit id: "S1 📸"
|
||||
commit id: "S2 📸"
|
||||
commit id: "S3 ✏️"
|
||||
commit id: "S4 🍓"
|
||||
commit id: "S5 🚀 deploy"
|
||||
```
|
||||
|
||||
- 📸 Every accepted change = an **immutable snapshot** (BLAKE3 of the manifest). Manifests are
|
||||
themselves content-addressed → 100 pushes don't store the tree map 100×.
|
||||
- ↩️ `devbox restore <snap> [path]` rolls back a file or whole share (itself a new change →
|
||||
reversible).
|
||||
- 🚢 `devbox deploy <share> <snap>` *(v1.5)* atomically pins a read-only mount to a snapshot —
|
||||
**blue/green deploys** for your `/var/www` boxes, basically free.
|
||||
- 🧹 `devbox-hub gc` sweeps unreferenced chunks (refcounted).
|
||||
|
||||
---
|
||||
|
||||
## 🖥️ Cross-Platform
|
||||
|
||||
<div align="center">
|
||||
|
||||
| Capability | 🐧 Linux | 🍎 macOS | 🪟 Windows |
|
||||
|---|:---:|:---:|:---:|
|
||||
| File watching | inotify | FSEvents | ReadDirectoryChangesW |
|
||||
| Atomic apply | `rename(2)` | `rename(2)` | `ReplaceFile`/`MoveFileEx` |
|
||||
| Hooks | bash | bash | bash *(git-bash/WSL)* or `.ps1`→pwsh |
|
||||
| Service | systemd | launchd | Windows Service |
|
||||
| Static binary | ✅ | ✅ | ✅ |
|
||||
|
||||
</div>
|
||||
|
||||
> 🧭 Canonical paths are **forward-slash + relative** (converted at the Windows boundary).
|
||||
> Filenames illegal/colliding on an OS (`foo.go` vs `Foo.go`, `aux`, trailing dot) → **skip +
|
||||
> warn + surface** in `devbox status`; the hub keeps the bytes, peers that *can* hold the name
|
||||
> still get the file. Never fatal. 🛟
|
||||
|
||||
---
|
||||
|
||||
## 🗺️ Roadmap
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
M0["M0 🦴\nSkeleton"] --> M1["M1 👀\nWatch + ignore\n+ secrets"]
|
||||
M1 --> M2["M2 🛰️\nHub + push\n+ /metrics"]
|
||||
M2 --> M3["M3 🔄\nTwo-way sync\n+ conflicts"]
|
||||
M3 --> M4["M4 🔒\nRead-only\n+ bandwidth"]
|
||||
M4 --> M5["M5 🪝\nHooks"]
|
||||
M5 --> M6["M6 🕰️\nVersioning"]
|
||||
M6 --> M65["M6.5 🚢\nDeploy"]
|
||||
M65 --> M7["M7 🛡️\nHardening"]
|
||||
style M0 fill:#4F9CF9,color:#fff
|
||||
```
|
||||
|
||||
| | Milestone | Deliverable |
|
||||
|:---:|---|---|
|
||||
| ⬜ | **M0 — Skeleton** 🦴 | cobra CLI, `devbox join`, keypair, machine config |
|
||||
| ⬜ | **M1 — Watch + secrets** 👀 | fsnotify, `.devignore`, secret-guard, content-addressed manifests |
|
||||
| ⬜ | **M2 — Hub + push** 🛰️ | shares, token, CAS, `publish`, HTTP upload, snapshots, `/metrics` |
|
||||
| ⬜ | **M3 — Two-way sync** 🔄 | WS events + HTTP blobs, mount/pull, atomic apply, conflict copies |
|
||||
| ⬜ | **M4 — Read-only + bw** 🔒 | server-enforced read-only bit, sub-path mounts, bandwidth cap |
|
||||
| ⬜ | **M5 — Hooks** 🪝 | bash/`.ps1` runner, templates, env, timeout |
|
||||
| ⬜ | **M6 — Versioning** 🕰️ | `log` / `restore`, hub GC |
|
||||
| ⬜ | **M6.5 — Deploy** 🚢 | `devbox deploy <share> <snapshot>` |
|
||||
| ⬜ | **M7 — Hardening** 🛡️ | `doctor`, reconnect/backoff, name-clash, arm64/mac/win releases |
|
||||
|
||||
<details>
|
||||
<summary>🔮 <b>v2 backlog</b></summary>
|
||||
|
||||
- 🤝 **LAN peer chunk-exchange** — co-located nodes swap chunks directly (Syncthing-style)
|
||||
- 🎛️ **Interactive conflict resolver** — diff + keep-mine/theirs/both/edit
|
||||
- 🔁 **Re-share / delegation** (the `s` permission)
|
||||
- 🧬 **Content-level 3-way text merge**
|
||||
- 🔋 **Laptop power sanity** — pause-on-metered / pause-on-battery / sync windows
|
||||
- 🔏 **Client-side E2E chunk encryption**
|
||||
- 🏰 **Hub clustering / HA**
|
||||
- 🖼️ **Full TUI** dashboard
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
|
||||
## ⚖️ License & Open-Core
|
||||
|
||||
<div align="center">
|
||||
|
||||
**📜 AGPLv3 core** — self-host free, forever. · **💼 Commercial license** for the hosted tier.
|
||||
|
||||
</div>
|
||||
|
||||
devbox is **open-core**: the entire hub + clients in this repo are AGPLv3 and fully
|
||||
self-hostable. A future **hosted version** (signup, billing, provisioning) is a separate, closed
|
||||
control plane that wraps the same single-tenant hub — designed for via clean seams (`BlobStore`
|
||||
interface, config-driven limits, `/metrics`) but **not part of this OSS repo**.
|
||||
|
||||
> Offering devbox as a hosted service? AGPLv3 means open your changes — or
|
||||
> [grab a commercial license](#). 🤝
|
||||
|
||||
---
|
||||
|
||||
## 🙌 Contributing
|
||||
|
||||
> 🚧 We're in design phase — the spec is the best place to start:
|
||||
> [`docs/superpowers/specs/2026-06-22-devbox-design.md`](docs/superpowers/specs/2026-06-22-devbox-design.md)
|
||||
|
||||
1. 🍴 Fork & branch
|
||||
2. 🧪 Keep it lazy-correct (smallest diff that works, tests for non-trivial logic)
|
||||
3. 📝 Update the docs in the same PR — they get the **full flare treatment** 😎
|
||||
4. 🚀 Open a PR
|
||||
|
||||
<div align="center">
|
||||
<br/>
|
||||
|
||||
### Made with 📦, ☕, and a healthy fear of `rm -rf` on the wrong machine.
|
||||
|
||||
*“It's like Dropbox, but it actually respects that you're a developer.”* 💙
|
||||
|
||||
<sub>🤖 Spec & scaffolding generated with <a href="https://claude.com/claude-code">Claude Code</a></sub>
|
||||
|
||||
</div>
|
||||
|
|
@ -1,29 +1,30 @@
|
|||
# devbox — v1 Design
|
||||
|
||||
> **One-liner:** Continuous, automatic file sync for developers — like Dropbox, but it
|
||||
> respects a `.devignore`, runs pre/post hooks on sync events, keeps Git-like version
|
||||
> history, and lets you mount *shares* (or sub-paths) across machines with per-device
|
||||
> permissions. It is *not* a Git replacement; it keeps your working directory live-synced
|
||||
> across machines without committing half-done work.
|
||||
> respects a `.devignore`, refuses to leak secrets, runs pre/post hooks on sync events, keeps
|
||||
> Git-like version history, and lets you mount *shares* (or sub-paths) across machines. It is
|
||||
> *not* a Git replacement; it keeps your working directory live-synced across machines without
|
||||
> committing half-done work.
|
||||
|
||||
Status: **approved design**, ready for implementation planning.
|
||||
Date: 2026-06-22.
|
||||
Date: 2026-06-22. (Revised post-audit: scope tightened, secret-guard/metrics/bandwidth-cap
|
||||
promoted into v1.)
|
||||
|
||||
---
|
||||
|
||||
## 1. Problem & Vision
|
||||
|
||||
Dropbox/iCloud sync everything blindly — they choke on `node_modules`, leak `.env`
|
||||
secrets, and thrash on build artifacts. Git is manual, commit-based, and not meant for
|
||||
continuously mirroring an in-progress working tree across machines. There is no good tool
|
||||
that says: *"keep these dev directories live-synced across my machines, skip the junk, run
|
||||
my commands when files land, and let me cherry-pick exactly what each machine gets."*
|
||||
Dropbox/iCloud sync everything blindly — they choke on `node_modules`, leak `.env` secrets,
|
||||
and thrash on build artifacts. Git is manual, commit-based, and not meant for continuously
|
||||
mirroring an in-progress working tree across machines. There is no good tool that says: *"keep
|
||||
these dev directories live-synced across my machines, skip the junk, never leak my secrets,
|
||||
run my commands when files land, and let me cherry-pick exactly what each machine gets."*
|
||||
|
||||
**devbox** fills that gap: a self-hostable **hub** publishes named **shares**; **devices**
|
||||
join the hub with a token and **mount** shares (or sub-paths) into any local directory with
|
||||
read/write permissions. A per-machine **daemon** watches every mount, filters via
|
||||
`.devignore`, syncs deltas through the hub to the device's other machines in near-real-time,
|
||||
fires lifecycle **hooks**, and keeps **snapshot history** per share.
|
||||
**devbox** fills that gap: a self-hostable **hub** publishes named **shares**; **devices** join
|
||||
the hub with a token and **mount** shares (or sub-paths) into any local directory, read-write
|
||||
or read-only. A per-machine **daemon** watches every mount, filters via `.devignore`, syncs
|
||||
deltas through the hub to the device's other machines in near-real-time, fires lifecycle
|
||||
**hooks**, and keeps **snapshot history** per share.
|
||||
|
||||
**Who it's for (v1):** developers running multiple machines / homelabs who want their active
|
||||
workspaces mirrored without Git ceremony. Fits a Pi 5 cluster + MacBook + TrueNAS setup
|
||||
|
|
@ -36,27 +37,31 @@ directly. Also the foundation of a future commercial hosted offering (see §13).
|
|||
### Goals
|
||||
- Continuous, automatic, **bidirectional** sync of shares across linked machines.
|
||||
- **Shares + selective mounts**: cherry-pick a whole share or any sub-path onto a machine,
|
||||
mapped to any local path, with per-mount permissions.
|
||||
mapped to any local path, read-write or read-only.
|
||||
- `.devignore` (gitignore syntax) to exclude paths from sync entirely.
|
||||
- **Hooks**: run user commands on sync lifecycle events (`pre-push`, `post-push`,
|
||||
`pre-pull`, `post-pull`, `on-conflict`).
|
||||
- **Default-on secret protection** — built-in deny-list hard-refuses to upload matched secret
|
||||
patterns even if `.devignore` is misconfigured.
|
||||
- **Hooks**: run user commands on sync lifecycle events.
|
||||
- **Version history** (Git-like snapshots, per share) so any synced file can be rolled back.
|
||||
- **Self-hostable hub** — single Go binary, runs on a Pi / TrueNAS, no SaaS dependency.
|
||||
- Delta/chunked transfer so big files and large trees both stay fast.
|
||||
- Delta/chunked transfer + a **bandwidth cap** so big files and large trees stay fast and don't
|
||||
saturate a link.
|
||||
- **Never silently lose work.** Conflicts never block and never destroy a byte.
|
||||
- **Hub observability** — `/metrics` + a status page.
|
||||
- **Fully cross-platform**: Linux, macOS, Windows.
|
||||
- Open-source core, with clean seams for a future commercial hosted tier.
|
||||
- Open-source (AGPLv3) core, with clean seams for a future commercial hosted tier.
|
||||
|
||||
### Non-Goals (v1)
|
||||
- Not a Git replacement — no branching/merging semantics, no PRs.
|
||||
- No TUI in v1 — `devbox` with no args prints rich text status. (Full TUI parked as a future
|
||||
"someday" todo.)
|
||||
- No TUI — `devbox` with no args prints rich text status. (Full TUI = future "someday" todo.)
|
||||
- No mobile/desktop GUI.
|
||||
- No teams/org ACLs. Single-owner, multi-device. (Permissions are per *device*, not per
|
||||
*user*.)
|
||||
- No re-share / delegation permission (`s`) — deferred to v2; flag syntax stays
|
||||
forward-compatible.
|
||||
- No content-level 3-way text merge — conflicts produce side-by-side copies (v2 question).
|
||||
- No multi-user roles/teams/ACLs. Single-owner, multi-device. The only access knob is a
|
||||
per-device-per-share **read-only** bit (deploy boxes can't push).
|
||||
- No interactive conflict resolver (mine/theirs/both/edit) — v1 lists conflicts; resolving by
|
||||
hand. Interactive resolver is v2.
|
||||
- No re-share/delegation permission — v2.
|
||||
- No content-level 3-way text merge — conflicts produce side-by-side copies (v2).
|
||||
- No LAN peer-to-peer chunk exchange — v1 is hub-centric; P2P block exchange is v2.
|
||||
- No client-side E2E chunk encryption (v2).
|
||||
|
||||
---
|
||||
|
|
@ -71,27 +76,34 @@ cross-compiled to `linux/arm64` (Pi), `darwin/arm64` (Mac), `windows/amd64`.
|
|||
| CLI + daemon (`devbox`, `devboxd`) | Go, `cobra` CLI | Static cross-compiled binaries, trivial Pi deploy |
|
||||
| File watching | `fsnotify`, debounced rescan | inotify / FSEvents / ReadDirectoryChangesW |
|
||||
| Ignore matching | gitignore-semantics matcher | `.devignore` = gitignore syntax |
|
||||
| Chunking / dedup | FastCDC content-defined chunking + BLAKE3 | Delta sync, dedup big files, content-addressed |
|
||||
| Transport | HTTP/2 for blobs + WebSocket for live change events | Simple, proxy-friendly (works behind Nginx Proxy Manager) |
|
||||
| Chunking / dedup | FastCDC content-defined chunking + BLAKE3 | Delta sync, dedup, content-addressed (manifests too) |
|
||||
| Transport | **WebSocket for change events + stateless HTTP for content-addressed blobs** | WS handles live events; HTTP gives range/resume/caching for bytes for free. Same TLS endpoint + bearer token. |
|
||||
| Hub metadata | SQLite (single-writer, WAL) | Zero-ops, fits homelab |
|
||||
| Blob storage | `BlobStore` interface — disk CAS (v1), S3/R2 impl later | Maps to TrueNAS now, object storage for hosted |
|
||||
| Auth | Device Ed25519 keypair + bearer token; Docker-style join tokens | No passwords, device-revocable |
|
||||
| Hooks runner | exec into **bash** (all OSes), env-injected | One hook language everywhere |
|
||||
| Auth | Device Ed25519 keypair + bearer token; single rotatable join token | No passwords, device-revocable |
|
||||
| Hooks runner | exec into **bash** (default, all OSes); `.ps1` hooks auto-run via `pwsh` on Windows | Portable hooks across the fleet; zero-config Windows opt-in |
|
||||
|
||||
> **Why not pure WebSocket?** A single WS is one ordered stream — a big blob upload
|
||||
> head-of-line-blocks event delivery, and WS has no range/resume/caching. Blobs over stateless
|
||||
> HTTP (`GET /blob/<hash>`, retry = re-request) is *less* code than reinventing resumable
|
||||
> transfer over a socket. Only the WS needs reconnect logic.
|
||||
|
||||
---
|
||||
|
||||
## 4. Core Concepts
|
||||
|
||||
- **Hub** — the server. Publishes shares, stores chunks (CAS) + metadata (SQLite), brokers
|
||||
change events. One owner, many devices. Self-hosted single binary.
|
||||
- **Hub** — the server. Publishes shares, stores chunks + manifests (CAS) + metadata (SQLite),
|
||||
brokers change events. One owner, many devices. Self-hosted single binary.
|
||||
- **Device** — a machine with an Ed25519 identity, joined to a hub. Runs one daemon.
|
||||
- **Share** — a named top-level tree on the hub (`projects`, `repos`, `services`). The unit
|
||||
of **permission** and of **snapshot history**.
|
||||
- **Grant** — what a device may do on a share: `r` (pull), `w` (push). Hub-authoritative.
|
||||
- **Mount** — a device-side binding: `share[/subpath] → localpath` with requested perms,
|
||||
clamped to the grant. A device has many mounts; one daemon watches them all.
|
||||
- **Share** — a named top-level tree on the hub (`projects`, `repos`, `services`). The unit of
|
||||
snapshot history.
|
||||
- **Mount** — a device-side binding: `share[/subpath] → localpath`, read-write or read-only. A
|
||||
device has many mounts; one daemon watches them all.
|
||||
- **Read-only bit** — a per-device-per-share `writable` flag on the hub (default writable). A
|
||||
non-writable device's pushes are rejected server-side — the only access control in v1.
|
||||
- **Snapshot** — an immutable per-share manifest version (id = BLAKE3 of manifest).
|
||||
- **Manifest** — `path → [chunk hashes] + mode + size` for a share at a point in time.
|
||||
- **Manifest** — `path → [chunk hashes] + mode + size` for a share at a point in time;
|
||||
itself content-addressed and stored in the CAS.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -101,62 +113,65 @@ cross-compiled to `linux/arm64` (Pi), `darwin/arm64` (Mac), `windows/amd64`.
|
|||
device (laptop) hub (Pi / TrueNAS) device (pi-07)
|
||||
devboxd devbox-hub devboxd
|
||||
├ mount: projects/ ──┐ ├ shares: projects, ┌──── mount: projects/p22/backend
|
||||
├ mount: repos/ ─────┼─ WS ─► │ repos, services │ (read-only -> /var/www)
|
||||
└ <mount>/.devbox/ │ HTTP ├ CAS blobs (BLAKE3) ─ WS ┤ └ hooks fire on pull
|
||||
hooks, .devignore └──────► ├ SQLite: snapshots, ────┘
|
||||
│ shares, grants,
|
||||
│ devices, tokens
|
||||
└ BlobStore: disk (v1) | S3/R2 (later)
|
||||
├ mount: repos/ ─────┤ WS │ repos, services │ (read-only -> /var/www)
|
||||
│ (events) ──────────┼──────► ├ change log / HEAD WS ──┤ └ hooks fire on pull
|
||||
│ (blobs) ───────────┼─HTTP─► ├ CAS: chunks + manifests │
|
||||
└ <mount>/.devbox/ │ ├ SQLite: snapshots, HTTP┘
|
||||
hooks, .devignore └──────► │ shares, devices,
|
||||
│ tokens, writable bits
|
||||
├ BlobStore: disk (v1) | S3/R2 (later)
|
||||
└ /metrics + status page
|
||||
```
|
||||
|
||||
### Sync loop (per mount, per machine)
|
||||
1. `fsnotify` reports a change in a mount's local tree (debounced ~300ms).
|
||||
2. Path checked against the compiled `.devignore`; ignored paths dropped.
|
||||
3. Changed files chunked (FastCDC) → BLAKE3 hashes → manifest diff vs last-known state.
|
||||
4. **`pre-push` hook** fires (can veto). New chunks uploaded to the hub (only ones it lacks).
|
||||
2. Path checked against `.devignore` **and the built-in secret deny-list**; matches dropped.
|
||||
3. Changed files chunked (FastCDC) → BLAKE3 → manifest diff vs last-known state.
|
||||
4. **`pre-push` hook** fires (can veto). New chunks uploaded over HTTP (only ones the hub
|
||||
lacks), subject to the bandwidth cap.
|
||||
5. Hub appends a snapshot, advances that **share's linear HEAD**, broadcasts a change event
|
||||
over WebSocket.
|
||||
6. **`post-push` hook** fires locally.
|
||||
7. Other devices with a mount on that share receive the event → **`pre-pull` hook** → fetch
|
||||
missing chunks → reassemble → **atomic rename into place** → **`post-pull` hook**.
|
||||
7. Other devices with a mount on that share receive the WS event → **`pre-pull` hook** → fetch
|
||||
missing chunks over HTTP → reassemble → **atomic rename into place** → **`post-pull` hook**.
|
||||
|
||||
A `w`-less (read-only) mount skips steps 3–6 (it never pushes) but still does 7.
|
||||
A read-only mount skips steps 3–6 (never pushes) but still does 7.
|
||||
|
||||
---
|
||||
|
||||
## 6. Shares, Mounts & Permissions
|
||||
|
||||
### Permissions
|
||||
- `r` = pull/receive, `w` = push your edits, `-a` = `rw`. No `s` in v1 (the file is already
|
||||
shared by being on the hub; re-share/delegation is v2).
|
||||
- **Hub-authoritative.** Each device has a grant per share. The client's `-rw`/`-a` flags are
|
||||
a *request*, **clamped** to the grant. Asking for `-w` on a read-only grant → read-only +
|
||||
a warning. A fat-fingered flag can't pollute canonical upstream.
|
||||
- **Tokens** (Docker-style, rotatable): `devbox-hub token manager|member`.
|
||||
- **Manager** token → device can create shares, mint tokens, manage/revoke devices, rw all.
|
||||
- **Member** token → device gets `rw` on shares by default; downgradable per share
|
||||
(`devbox-hub grant pi-07 projects r` for a read-only deploy box).
|
||||
|
||||
### Creating a share
|
||||
`devbox publish <localdir> <name>` (manager/write capability). Publishing is the explicit
|
||||
verb (since `s` is gone, share creation is not a mount flag).
|
||||
## 6. Shares, Mounts & Read-Only
|
||||
|
||||
### Mounting
|
||||
`devbox -rw <share>[/subpath] [localpath]` — mount a whole share or any sub-path to any local
|
||||
path. Default `localpath` = `./<last-path-segment>`.
|
||||
`devbox -rw <share>[/subpath] [localpath]` mounts a whole share or any sub-path to any local
|
||||
path. Default `localpath` = `./<last-path-segment>`. `-r` = read-only, `-a`/`-rw` = read-write.
|
||||
|
||||
```
|
||||
devbox -a projects ./ # whole share, rw, here
|
||||
devbox -a projects ./ # whole share, rw, here
|
||||
devbox -r projects/p22/backend /var/www/p22/backend # one sub-path, read-only, elsewhere
|
||||
```
|
||||
|
||||
A mount is recorded in `~/.config/devbox/daemon.toml` (see §8).
|
||||
|
||||
### Access model (deliberately minimal)
|
||||
v1 is **single-owner**, so there are no roles, no grants ACL, no flag-clamping subsystem. Every
|
||||
enrolled device is `rw` by default. The one real need — *deploy boxes must not push* — is a
|
||||
single **server-enforced** `writable` bit per (device, share):
|
||||
|
||||
- Set on the hub: `devbox-hub readonly <device> <share>` → the hub rejects that device's pushes.
|
||||
- Server-enforced on purpose: a read-only deploy box *cannot* pollute canonical even if its
|
||||
local flag is wrong or the client is compromised. (A purely client-side flag would be a
|
||||
footgun.)
|
||||
|
||||
### Creating a share
|
||||
`devbox publish <localdir> <name>` — any writable device can create a share from a local folder
|
||||
and push it. Admin (`devbox-hub …`) runs on the hub host (whoever has shell there); device
|
||||
management isn't a device privilege.
|
||||
|
||||
### Read-only mounts & data safety
|
||||
A read-only mount pulls but never pushes. To still honor "never lose a byte": if an inbound
|
||||
change would clobber a **locally-modified** file on a read-only mount, devbox first stashes
|
||||
the local version as `path.conflict-local-<ts>.ext` (preserved on disk, never pushed), then
|
||||
applies the inbound change. So even pull-only boxes never lose local edits.
|
||||
change would clobber a **locally-modified** file on a read-only mount, devbox first stashes the
|
||||
local version as `path.conflict-local-<ts>.ext` (preserved on disk, never pushed), then applies
|
||||
the inbound change.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -168,36 +183,29 @@ The mechanism behind "Dropbox-easy, never loses data." Runs **per share**.
|
|||
pushes for free.
|
||||
- A push declares the snapshot it was based on (`parent_id`).
|
||||
- `parent == HEAD` → fast-forward: accept, advance HEAD.
|
||||
- `parent != HEAD` → **per-file 3-way** vs the common ancestor (the pusher's `parent`
|
||||
snapshot):
|
||||
- File changed by **only** the pusher → applies cleanly.
|
||||
- File changed by **both** sides → **conflict**: the first-to-land (current HEAD) stays
|
||||
**canonical**; the loser is written beside it as `path.conflict-<host>-<ts>.ext`;
|
||||
`on-conflict` fires. The conflict copy is itself a new path → it syncs everywhere, so
|
||||
no edit is ever lost.
|
||||
- **Comparison is by BLAKE3 content hash**, not timestamps. Touching a file without changing
|
||||
bytes is a no-op — no false conflict.
|
||||
- **Deletes** propagate (it's sync) but are always recoverable from snapshots.
|
||||
**Delete-vs-edit never loses the edit:** a delete has no bytes to preserve, so the edit
|
||||
always wins (survives as canonical, or as a `.conflict` copy if it lost ordering).
|
||||
- **Renames are free**: old-path-gone + new-path-added; chunks are content-addressed, so zero
|
||||
bytes re-transfer. No special rename detection in v1.
|
||||
- **Initial mount/bootstrap**: mounting a share onto a non-empty local dir reconciles per-file
|
||||
against the hub HEAD via the same conflict path (ancestor = empty). Matching files (by hash)
|
||||
are kept; differing local files become `.conflict` copies; the hub stays canonical.
|
||||
- `parent != HEAD` → **per-file 3-way** vs the common ancestor (the pusher's `parent`):
|
||||
- Changed by **only** the pusher → applies cleanly.
|
||||
- Changed by **both** → **conflict**: first-to-land (current HEAD) stays **canonical**; the
|
||||
loser is written beside it as `path.conflict-<host>-<ts>.ext`; `on-conflict` fires. The
|
||||
conflict copy is a new path → it syncs everywhere, so no edit is ever lost.
|
||||
- **Comparison is by BLAKE3 content hash**, not timestamps — touching a file without changing
|
||||
bytes is a no-op.
|
||||
- **Deletes** propagate (recoverable from snapshots). **Delete-vs-edit never loses the edit** —
|
||||
a delete has no bytes to preserve, so the edit always wins (canonical, or a `.conflict` copy).
|
||||
- **Renames are free** — old-path-gone + new-path-added; content-addressed chunks mean zero
|
||||
bytes re-transfer.
|
||||
- **Initial mount/bootstrap** — mounting onto a non-empty dir reconciles per-file against HEAD
|
||||
via the same conflict path (ancestor = empty).
|
||||
|
||||
**Never blocks. Never asks. Never destroys a byte.**
|
||||
|
||||
### Conflict UX (per-machine, configurable in `config.toml`)
|
||||
All four modes ship; each is a toggle. Default = non-blocking (badge + hook + resolver).
|
||||
- **Status badge** — `devbox status` always shows pending-conflict count. Pull-based, zero
|
||||
interruption. (Always on.)
|
||||
- **`on-conflict` push alert** — a default hook fires when a conflict copy is created; wire it
|
||||
to ntfy/desktop/Slack. Non-blocking.
|
||||
- **`devbox conflicts` resolver** — list, diff, resolve on demand: keep-mine / keep-theirs /
|
||||
keep-both / open-in-`$EDITOR`. You choose when to look.
|
||||
- **Blocking prompt** — *opt-in only*. Daemon prompts at conflict time. Off by default
|
||||
(breaks Dropbox-ease); available for those who want it.
|
||||
### Conflict UX (one mode, not four)
|
||||
- **Conflict copies** land on disk next to the canonical file (always).
|
||||
- **`devbox status`** shows a pending-conflict count + lists the copies. (Always on.)
|
||||
- **`on-conflict` hook** is the notification API — wire it to ntfy/desktop/Slack.
|
||||
- **`devbox conflicts`** lists the conflict files (read-only listing) so you can find and clean
|
||||
them. *(Interactive resolve — mine/theirs/both/edit — is v2. No blocking prompt: a headless
|
||||
daemon can't prompt and it would break "never asks.")*
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -205,54 +213,52 @@ All four modes ship; each is a toggle. Default = non-blocking (badge + hook + re
|
|||
|
||||
- **Machine-global** `~/.config/devbox/`:
|
||||
- Ed25519 keypair (one identity per device; **never leaves the box**).
|
||||
- `daemon.toml` — the mount list (share, subpath, localpath, perms, hub).
|
||||
- `config.toml` — global defaults (conflict-UX prefs, hook timeout, etc.).
|
||||
- `daemon.toml` — the mount list (share, subpath, localpath, readonly, hub).
|
||||
- `config.toml` — global settings.
|
||||
- **Per-mount** `<localpath>/.devbox/`:
|
||||
- `hooks/` — per-machine lifecycle scripts (never synced).
|
||||
- last-synced snapshot id, mount-local config overrides.
|
||||
- last-synced snapshot id, mount-local overrides.
|
||||
- Always implicitly ignored from sync.
|
||||
- **`.devignore`** — a *synced* file at a share root (gitignore syntax, shared across
|
||||
devices). Nested `.devignore` files allowed, scoped to their subtree.
|
||||
- **`.devignore`** — a *synced* file at a share root (gitignore syntax). Nested ones allowed.
|
||||
|
||||
```toml
|
||||
# ~/.config/devbox/daemon.toml
|
||||
[[mount]]
|
||||
share = "projects"
|
||||
subpath = ""
|
||||
local = "/Users/jh/Projects"
|
||||
perms = "rw"
|
||||
hub = "hub.shoemoney.ai"
|
||||
hub = "hub.shoemoney.ai"
|
||||
|
||||
[[mount]]
|
||||
share = "projects"
|
||||
subpath = "p22/backend"
|
||||
local = "/var/www/p22/backend"
|
||||
perms = "r"
|
||||
subpath = "p22/backend"
|
||||
local = "/var/www/p22/backend"
|
||||
readonly = true
|
||||
hub = "hub.shoemoney.ai"
|
||||
```
|
||||
|
||||
```toml
|
||||
# ~/.config/devbox/config.toml
|
||||
[conflicts]
|
||||
badge = true # always on
|
||||
on_conflict_hook = true
|
||||
resolver = true
|
||||
blocking_prompt = false # opt-in
|
||||
|
||||
[hooks]
|
||||
interpreter = "bash" # all OSes; Windows needs git-bash/WSL (devbox doctor checks)
|
||||
# bash everywhere; a .ps1 hook auto-runs via pwsh on Windows
|
||||
interpreter = "bash"
|
||||
timeout_secs = 60
|
||||
|
||||
[transfer]
|
||||
max_kbps = 0 # 0 = unlimited; cap to protect a link
|
||||
|
||||
[secrets]
|
||||
# built-in deny-list always on; add extra patterns here
|
||||
extra_patterns = []
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 9. `.devignore` Spec
|
||||
## 9. `.devignore` + Secret Guard
|
||||
|
||||
Gitignore syntax, evaluated relative to the share/mount root. Lives at the share root; nested
|
||||
`.devignore` files allowed and scoped to their subtree.
|
||||
### `.devignore`
|
||||
Gitignore syntax, relative to the share/mount root; nested files allowed.
|
||||
|
||||
```
|
||||
# devbox: paths here are NEVER synced
|
||||
node_modules/
|
||||
vendor/
|
||||
dist/
|
||||
|
|
@ -262,38 +268,38 @@ target/
|
|||
*.log
|
||||
*.tmp
|
||||
.DS_Store
|
||||
|
||||
# secrets: never leave the machine
|
||||
.env
|
||||
.env.*
|
||||
*.pem
|
||||
*.key
|
||||
secrets/
|
||||
|
||||
# negate to force-include
|
||||
!.env.example
|
||||
```
|
||||
|
||||
- A matched path is invisible to sync in **both** directions (won't upload, won't accept
|
||||
inbound writes).
|
||||
- `!pattern` negation re-includes, gitignore precedence.
|
||||
- Changing `.devignore` triggers a rescan; newly-ignored files are **left on disk** (never
|
||||
deleted) but stop syncing.
|
||||
- A matched path is invisible to sync in **both** directions.
|
||||
- `!pattern` negation re-includes (gitignore precedence).
|
||||
- Changing `.devignore` triggers a rescan; newly-ignored files are **left on disk** but stop
|
||||
syncing.
|
||||
- `.devbox/` is always implicitly ignored.
|
||||
|
||||
### Secret guard (default-on, independent of `.devignore`)
|
||||
A built-in deny-list runs in the push path and **hard-refuses to upload** matched files, even
|
||||
if `.devignore` is misconfigured. This is the "won't leak your secrets" guarantee, enforced —
|
||||
not an optional hook.
|
||||
|
||||
Default patterns: `.env`, `.env.*` (except `.env.example`), `*.pem`, `*.key`, `id_rsa*`,
|
||||
`*.p12`, `*.pfx`, `secrets/`, `*.kdbx`, common cloud-credential files. Add more via
|
||||
`[secrets].extra_patterns`. A blocked file surfaces in `devbox status`. (A `pre-push`
|
||||
secret-scan hook can still add belt-and-suspenders scanning of file *contents*.)
|
||||
|
||||
---
|
||||
|
||||
## 10. Hooks Spec
|
||||
|
||||
Per-machine scripts in `<mount>/.devbox/hooks/`, named after the event, **never synced**.
|
||||
devbox shells out to `bash <hook>` on every OS (one hook language; `devbox doctor` flags a
|
||||
missing bash and points Windows users at git-bash/WSL). Non-zero exit on a `pre-*` hook
|
||||
**aborts** that sync step. Default timeout 60s — a hung hook is killed + logged, never wedges
|
||||
the loop.
|
||||
devbox shells out to **bash** by default (one portable hook language across your fleet); a hook
|
||||
file ending in `.ps1` auto-runs via `pwsh` on Windows (zero-config opt-in). `devbox doctor`
|
||||
flags a missing interpreter. Non-zero exit on a `pre-*` hook **aborts** that step. Default
|
||||
timeout 60s — a hung hook is killed + logged, never wedges the loop.
|
||||
|
||||
| Hook | Fires | Can abort? | Typical use |
|
||||
| --- | --- | --- | --- |
|
||||
| `pre-push` | before local changes upload | ✅ | lint/format, block on secret scan |
|
||||
| `pre-push` | before local changes upload | ✅ | lint/format, secret scan |
|
||||
| `post-push` | after upload confirmed | ❌ | notify, log, tag a snapshot |
|
||||
| `pre-pull` | before inbound changes apply | ✅ | stop a container/dev server |
|
||||
| `post-pull` | after inbound changes applied | ❌ | `pnpm install`, migrate, restart service |
|
||||
|
|
@ -302,10 +308,10 @@ the loop.
|
|||
### Injected environment
|
||||
```bash
|
||||
DEVBOX_EVENT=post-pull
|
||||
DEVBOX_MOUNT=/srv/project # local mount root
|
||||
DEVBOX_MOUNT=/srv/project
|
||||
DEVBOX_SHARE=projects
|
||||
DEVBOX_HOST=pi-node-07
|
||||
DEVBOX_CHANGED_FILES=/tmp/devbox-changes.txt # newline-delimited list
|
||||
DEVBOX_CHANGED_FILES=/tmp/devbox-changes.txt
|
||||
DEVBOX_SNAPSHOT=ab12cd34
|
||||
DEVBOX_REMOTE=hub.shoemoney.ai
|
||||
```
|
||||
|
|
@ -313,7 +319,6 @@ DEVBOX_REMOTE=hub.shoemoney.ai
|
|||
### Example `post-pull`
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
# reinstall deps only if manifest changed, then restart the container
|
||||
if grep -qE 'package\.json|pnpm-lock\.yaml' "$DEVBOX_CHANGED_FILES"; then
|
||||
pnpm install --frozen-lockfile
|
||||
fi
|
||||
|
|
@ -322,61 +327,58 @@ docker compose restart app
|
|||
|
||||
---
|
||||
|
||||
## 11. Versioning / Snapshots
|
||||
## 11. Versioning / Snapshots / Deploy
|
||||
|
||||
- Every accepted change set on a share creates an immutable **snapshot** (id = BLAKE3 of the
|
||||
manifest). Cheap — chunks are content-addressed and deduped across all shares.
|
||||
manifest). The **manifest itself is content-addressed** and stored in the CAS — identical or
|
||||
near-identical manifests dedup, so 100 pushes don't store the path→chunks map 100×.
|
||||
- `devbox log` lists snapshots; `devbox restore <snapshot> [path]` rolls a file or the whole
|
||||
share back (a restore is itself a new change → fully reversible).
|
||||
- Retention configurable on the hub (keep all / keep N / time-window). `devbox-hub gc`
|
||||
garbage-collects unreferenced chunks via refcounts.
|
||||
share back (a restore is itself a new change → reversible).
|
||||
- **`devbox deploy <share> <snapshot>`** (v1.5/M6.5) — atomically pin a read-only mount to a
|
||||
specific snapshot. Blue/green deploys for `/var/www`-style boxes, nearly free since snapshots
|
||||
are already immutable.
|
||||
- Retention configurable on the hub; `devbox-hub gc` garbage-collects unreferenced chunks via
|
||||
refcounts.
|
||||
|
||||
---
|
||||
|
||||
## 12. Cross-Platform Handling (Linux / macOS / Windows)
|
||||
|
||||
Go cross-compiles to all three; `fsnotify` covers inotify / FSEvents / ReadDirectoryChangesW.
|
||||
Explicit handling for what doesn't come free:
|
||||
|
||||
- **Paths**: canonical form is **forward-slash, relative**; convert to `\` only at the Windows
|
||||
filesystem boundary.
|
||||
- **Atomic apply**: `os.Rename`-over-existing isn't atomic on Windows → use
|
||||
`ReplaceFile`/`MoveFileEx` there; POSIX `rename(2)` elsewhere.
|
||||
- **Name clashes / reserved names**: a Linux box can create `foo.go` *and* `Foo.go`, or files
|
||||
named `aux`/`com1`/with a trailing dot — illegal or colliding on Mac/Windows. Policy:
|
||||
**skip + warn + surface** under "unsyncable here" in `devbox status`. The hub keeps the
|
||||
bytes; OSes that can hold the name still get the file. Never fatal, never blocks the tree.
|
||||
- **Line endings**: bytes synced verbatim; devbox does not normalize CRLF/LF (out of scope).
|
||||
- **Service install**: `devbox start|stop` abstracts launchd (mac) / systemd (linux) /
|
||||
Windows Service.
|
||||
- **Hooks**: bash everywhere (see §10); `devbox doctor` verifies bash on PATH.
|
||||
- **Atomic apply**: `ReplaceFile`/`MoveFileEx` on Windows; POSIX `rename(2)` elsewhere.
|
||||
- **Name clashes / reserved names** (`foo.go` vs `Foo.go`, `aux`/`com1`, trailing dot):
|
||||
**skip + warn + surface** under "unsyncable here" in `devbox status`. The hub keeps the bytes;
|
||||
OSes that can hold the name still get the file. Never fatal.
|
||||
- **Line endings**: bytes synced verbatim; no CRLF/LF normalization.
|
||||
- **Service install**: `devbox start|stop` abstracts launchd / systemd / Windows Service.
|
||||
- **Hooks**: bash default; `.ps1` → `pwsh` on Windows; `devbox doctor` verifies the interpreter.
|
||||
|
||||
---
|
||||
|
||||
## 13. Open-Core / Commercial Model
|
||||
|
||||
**Open-source core + commercial hosted tier.** The OSS product is the fully self-hostable hub
|
||||
+ clients (this entire v1 spec). The hosted version is a **separate, closed control plane**
|
||||
(signup, billing, quotas, provisioning) — **out of scope for v1**, but the core carries clean
|
||||
seams so it isn't a retrofit:
|
||||
**Open-source core + commercial hosted tier.** The OSS product is the fully self-hostable hub +
|
||||
clients (this entire v1). The hosted version is a **separate, closed control plane** (signup,
|
||||
billing, quotas, provisioning) — **out of scope for v1**, but the core carries clean seams:
|
||||
|
||||
- **`BlobStore` interface** — disk CAS impl in v1 (Pi/TrueNAS); S3/R2 impl dropped in later
|
||||
for the hosted tier. One interface, one implementation now.
|
||||
- **Config-driven limits** — the hub reads `max_storage`, `retention`, `max_devices` from
|
||||
config. Self-host = unlimited; the commercial layer sets these per plan tier.
|
||||
- **`BlobStore` interface** — disk CAS (v1); S3/R2 impl later for hosted.
|
||||
- **Config-driven limits** — `max_storage`, `retention`, `max_devices`; self-host unlimited, the
|
||||
commercial layer sets them per tier.
|
||||
- **`/metrics` + status page** — observability now; doubles as the hosted dashboard seam.
|
||||
- **Single-tenant core** — the OSS hub knows nothing about accounts/billing.
|
||||
|
||||
### License (decided): AGPLv3 core + commercial license for the hosted tier
|
||||
Self-host free; anyone offering it as a hosted service must open their mods or buy a
|
||||
commercial license. Add a contributor CLA once outside PRs arrive (so dual-licensing stays
|
||||
possible). Revisit only if adoption friction (corp AGPL bans) becomes a real funnel problem.
|
||||
Self-host free; anyone offering it as a hosted service must open their mods or buy a commercial
|
||||
license. Add a contributor CLA once outside PRs arrive (keeps dual-licensing possible).
|
||||
|
||||
### Parked recommendations (confirm before launching hosting — neither changes the v1 build):
|
||||
### Parked recommendations (confirm before launching hosting — don't change the v1 build):
|
||||
- **Tenancy**: per-tenant hub instance — the control plane provisions one clean single-tenant
|
||||
hub (own SQLite + blob bucket) per account. Zero tenancy code in the OSS core; strong
|
||||
isolation. Multi-tenant consolidation is a later scale optimization.
|
||||
- **Pricing**: small monthly fee, discount for annual. Storage/device/retention tiers enforced
|
||||
via the config knobs above.
|
||||
hub (own SQLite + blob bucket) per account. Zero tenancy code in the OSS core. Multi-tenant
|
||||
consolidation is a later scale optimization.
|
||||
- **Pricing**: small monthly fee, discount for annual. Tiers enforced via the config knobs.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -384,10 +386,11 @@ possible). Revisit only if adoption friction (corp AGPL bans) becomes a real fun
|
|||
|
||||
- Each device generates an **Ed25519** keypair on first run; the private key never leaves the
|
||||
machine. Joining a hub authorizes the device's pubkey.
|
||||
- **Join tokens** (manager/member) enroll devices; tokens are rotatable and one-time/expiring.
|
||||
- A single **join token** (rotatable, expiring) enrolls devices: `devbox join <hub> <token>`.
|
||||
- All hub traffic over **TLS** (behind Nginx Proxy Manager / Let's Encrypt).
|
||||
- `.devignore` secret patterns keep `.env`, keys, etc. on the machine. Optional `pre-push`
|
||||
secret-scan hook as belt-and-suspenders.
|
||||
- **Secret guard** (§9) keeps `.env`, keys, etc. on the machine — enforced in the push path,
|
||||
default-on, independent of `.devignore`.
|
||||
- **Read-only enforcement** (§6) is server-side — a non-writable device can't push.
|
||||
- **Revoke** a lost device with `devbox-hub device revoke <id>` — its bearer token dies
|
||||
immediately.
|
||||
- (Deferred to v2) optional client-side E2E chunk encryption so the hub stores only ciphertext.
|
||||
|
|
@ -398,27 +401,28 @@ possible). Revisit only if adoption friction (corp AGPL bans) becomes a real fun
|
|||
|
||||
```
|
||||
# device
|
||||
devbox join <hub> <token> # enroll this device (Docker-style)
|
||||
devbox -rw <share>[/sub] [path] # mount a share/sub-path (default path ./<name>)
|
||||
devbox -a <share> [path] # mount with all (rw) perms
|
||||
devbox publish <localdir> <name> # create a share from a local folder (manager/write)
|
||||
devbox join <hub> <token> # enroll this device
|
||||
devbox -rw <share>[/sub] [path] # mount a share/sub-path read-write (default ./<name>)
|
||||
devbox -r <share>[/sub] [path] # mount read-only
|
||||
devbox publish <localdir> <name> # create a share from a local folder (writable device)
|
||||
devbox unmount <share> # stop syncing a mount (files stay on disk)
|
||||
devbox start | stop # run/stop the daemon (devboxd)
|
||||
devbox status # rich text: shares, mounts, peers, conflicts, pending
|
||||
devbox status # rich text: shares, mounts, peers, conflicts, blocked secrets
|
||||
devbox pause | resume # halt sync without unmounting
|
||||
devbox log # snapshot history
|
||||
devbox restore <snap> [path] # roll back a file or a whole share
|
||||
devbox conflicts # list + diff + resolve (mine/theirs/both/edit)
|
||||
devbox deploy <share> <snap> # pin a read-only mount to a snapshot (v1.5)
|
||||
devbox conflicts # list conflict copies (interactive resolve = v2)
|
||||
devbox ignore <pattern> # append to .devignore + rescan
|
||||
devbox hook edit <event> # open a hook script in $EDITOR
|
||||
devbox peers # linked machines, online/offline, last seen
|
||||
devbox doctor # diagnose watcher limits, perms, bash, connectivity
|
||||
devbox doctor # diagnose watcher limits, perms, hook interpreter, connectivity
|
||||
|
||||
# hub
|
||||
# hub (run on the hub host)
|
||||
devbox-hub serve --config /etc/devbox-hub.toml
|
||||
devbox-hub token manager|member # mint a rotatable join token
|
||||
devbox-hub token # mint/rotate the join token
|
||||
devbox-hub device list | revoke <id>
|
||||
devbox-hub grant <device> <share> r|rw
|
||||
devbox-hub readonly <device> <share> # mark a device read-only on a share (toggle)
|
||||
devbox-hub gc # garbage-collect unreferenced chunks
|
||||
```
|
||||
|
||||
|
|
@ -433,14 +437,12 @@ CREATE TABLE devices (
|
|||
id TEXT PRIMARY KEY, -- pubkey fingerprint
|
||||
name TEXT NOT NULL,
|
||||
pubkey BLOB NOT NULL,
|
||||
role TEXT NOT NULL, -- 'manager' | 'member'
|
||||
last_seen INTEGER,
|
||||
revoked INTEGER DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE tokens (
|
||||
hash TEXT PRIMARY KEY, -- hash of the join token
|
||||
role TEXT NOT NULL, -- 'manager' | 'member'
|
||||
expires_at INTEGER,
|
||||
used INTEGER DEFAULT 0
|
||||
);
|
||||
|
|
@ -452,35 +454,32 @@ CREATE TABLE shares (
|
|||
created_at INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE grants (
|
||||
-- only access control in v1: a per-(device,share) writable bit. Row present + writable=0 => read-only.
|
||||
CREATE TABLE access (
|
||||
device_id TEXT NOT NULL,
|
||||
share TEXT NOT NULL,
|
||||
perms TEXT NOT NULL, -- 'r' | 'rw'
|
||||
writable INTEGER NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (device_id, share)
|
||||
);
|
||||
|
||||
CREATE TABLE snapshots (
|
||||
id TEXT PRIMARY KEY, -- blake3(manifest)
|
||||
share TEXT NOT NULL,
|
||||
parent_id TEXT,
|
||||
device_id TEXT NOT NULL,
|
||||
created_at INTEGER NOT NULL,
|
||||
manifest BLOB NOT NULL -- gzipped: path -> [chunk hashes], mode, size
|
||||
id TEXT PRIMARY KEY, -- blake3(manifest)
|
||||
share TEXT NOT NULL,
|
||||
parent_id TEXT,
|
||||
device_id TEXT NOT NULL,
|
||||
created_at INTEGER NOT NULL,
|
||||
manifest_hash TEXT NOT NULL -- manifest stored content-addressed in the CAS
|
||||
);
|
||||
|
||||
CREATE TABLE chunks (
|
||||
hash TEXT PRIMARY KEY, -- blake3
|
||||
hash TEXT PRIMARY KEY, -- blake3 (chunks AND manifests live here)
|
||||
size INTEGER NOT NULL,
|
||||
refcount INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
```
|
||||
|
||||
Blobs stored via the `BlobStore` interface; disk impl at `blobs/<first2>/<hash>`,
|
||||
content-addressed and **deduped across all shares**. Refcounts drive GC.
|
||||
|
||||
> `ponytail:` manifest is a full gzipped BLOB per snapshot — fine to tens-of-thousands of
|
||||
> files once `.devignore` cuts the fat. If trees get huge, chunk the manifest itself
|
||||
> (content-address it like any other blob).
|
||||
Blobs (chunks + manifests) stored via the `BlobStore` interface; disk impl at
|
||||
`blobs/<first2>/<hash>`, content-addressed and **deduped across all shares**. Refcounts drive GC.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -489,17 +488,17 @@ content-addressed and **deduped across all shares**. Refcounts drive GC.
|
|||
| M | Deliverable | Done = |
|
||||
| --- | --- | --- |
|
||||
| **M0 — Skeleton** | Go monorepo, `cobra` CLI, `devbox join`, keypair gen, machine config | `devbox join` enrolls a device against a hub |
|
||||
| **M1 — Watch + ignore** | `fsnotify` watcher, `.devignore` matcher, manifest builder (per mount) | Edits produce a correct filtered manifest diff |
|
||||
| **M2 — Hub + one-way push** | `devbox-hub serve`, shares, tokens, `BlobStore` (disk CAS), `publish`, chunk upload, snapshots | A device publishes a share and pushes; snapshots land |
|
||||
| **M3 — Two-way sync** | WebSocket fan-out, mount/pull, atomic apply, per-file 3-way conflict copies | Two devices stay mirrored live; conflicts produce copies |
|
||||
| **M4 — Permissions** | manager/member tokens, read-only grants, sub-path mounts, flag clamping, read-only data-safety stash | A read-only deploy mount pulls and never pushes |
|
||||
| **M5 — Hooks** | bash lifecycle runner, templates, env injection, timeout | `post-pull` runs `pnpm install` on a Pi node |
|
||||
| **M1 — Watch + ignore + secret-guard** | `fsnotify` watcher, `.devignore` matcher, secret deny-list, content-addressed manifest builder | Edits produce a correct filtered manifest diff; secrets are refused |
|
||||
| **M2 — Hub + one-way push** | `devbox-hub serve`, shares, join token, `BlobStore` (disk CAS for chunks + manifests), `publish`, chunk upload over HTTP, snapshots, `/metrics` + status page | A device publishes a share and pushes; snapshots land; hub is observable |
|
||||
| **M3 — Two-way sync** | WS events + HTTP blob fetch, mount/pull, atomic apply, per-file 3-way conflict copies, `devbox status` badge + `devbox conflicts` list + `on-conflict` hook | Two devices stay mirrored live; conflicts produce copies |
|
||||
| **M4 — Read-only + bandwidth** | Server-enforced `writable` bit, `devbox-hub readonly`, read-only data-safety stash, sub-path mounts, bandwidth cap | A read-only deploy mount pulls, never pushes; transfers respect the cap |
|
||||
| **M5 — Hooks** | bash (+`.ps1`) lifecycle runner, templates, env injection, timeout | `post-pull` runs `pnpm install` on a Pi node |
|
||||
| **M6 — Versioning** | `devbox log` / `restore`, hub GC | Roll back any file from history |
|
||||
| **M7 — Hardening** | `devbox doctor`, watcher-limit handling, reconnect/backoff, name-clash handling, arm64/mac/win release builds | Survives reboots & flaky network on the cluster |
|
||||
| **M6.5 — Deploy** | `devbox deploy <share> <snapshot>` (pin read-only mount to a snapshot) | Blue/green flip a services box to a known snapshot |
|
||||
| **M7 — Hardening** | `devbox doctor`, watcher-limit handling, WS reconnect/backoff, name-clash handling, arm64/mac/win release builds | Survives reboots & flaky network on the cluster |
|
||||
|
||||
> Open-core seams (BlobStore interface, config-driven limits) land naturally in M2.
|
||||
> Commercial control plane (accounts/billing/provisioning) is a **separate sub-project**,
|
||||
> not part of this v1.
|
||||
> Open-core seams (BlobStore interface, config limits, `/metrics`) land in M2. The commercial
|
||||
> control plane (accounts/billing/provisioning) is a **separate sub-project**, not part of v1.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -513,13 +512,14 @@ devbox/
|
|||
├── internal/
|
||||
│ ├── watch/ # fsnotify + debounce
|
||||
│ ├── ignore/ # .devignore matcher
|
||||
│ ├── secret/ # default-on secret deny-list (push-path guard)
|
||||
│ ├── chunk/ # FastCDC + blake3
|
||||
│ ├── manifest/ # tree state + diff
|
||||
│ ├── mount/ # mount config, perms, clamping
|
||||
│ ├── manifest/ # tree state + diff (content-addressed)
|
||||
│ ├── mount/ # mount config, read-only enforcement
|
||||
│ ├── sync/ # push/pull engine, conflict resolution
|
||||
│ ├── hooks/ # lifecycle runner (bash)
|
||||
│ ├── transport/ # ws + http client
|
||||
│ └── hub/ # server, sqlite, shares, grants, tokens, CAS, gc
|
||||
│ ├── hooks/ # lifecycle runner (bash/.ps1)
|
||||
│ ├── transport/ # ws (events) + http (blobs) client
|
||||
│ └── hub/ # server, sqlite, shares, access, tokens, CAS, gc, metrics
|
||||
│ └── blobstore/ # BlobStore interface: disk (v1), s3/r2 (later)
|
||||
├── pkg/proto/ # shared wire types
|
||||
└── deploy/ # systemd/launchd/winsvc units, docker-compose for hub
|
||||
|
|
@ -530,50 +530,28 @@ devbox/
|
|||
## 19. Key Risks / Open Decisions
|
||||
|
||||
- **Watcher limits at scale** — large trees blow past inotify limits on Linux; mitigated by
|
||||
`.devignore` cutting `node_modules` etc., plus a fallback periodic rescan and `devbox
|
||||
doctor` to raise `fs.inotify.max_user_watches`.
|
||||
- **Conflict UX depth** — v1 keeps `.conflict` copies; content-level 3-way text merge is a v2
|
||||
question.
|
||||
- **Hub HA** — v1 is single-hub (SQLite). For a large cluster, run the hub on one stable node
|
||||
+ TrueNAS-backed blob dir; clustering the hub is v2.
|
||||
- **License & tenancy** — parked recommendations in §13; confirm before launching hosting.
|
||||
- **Central hub vs P2P** — central hub for v1 (simpler, matches the "Dropbox" mental model,
|
||||
always-on infra exists). A P2P mesh transport can be added later without changing the
|
||||
CLI/hook contract.
|
||||
`.devignore` cutting `node_modules`, a fallback periodic rescan, and `devbox doctor` to raise
|
||||
`fs.inotify.max_user_watches`.
|
||||
- **Hub uplink saturation** — 40 nodes pulling one big change strains the hub's link. v1
|
||||
mitigations: bandwidth cap + `.devignore`. The real fix (LAN peer chunk exchange) is v2.
|
||||
- **Hub HA** — v1 is single-hub (SQLite). Run it on one stable node + TrueNAS-backed blob dir;
|
||||
clustering is v2.
|
||||
- **Central hub vs P2P** — central hub for v1; a P2P mesh transport can be added later without
|
||||
changing the CLI/hook contract.
|
||||
|
||||
---
|
||||
|
||||
## 20. Backlog & Audit Notes
|
||||
## 20. v2 Backlog
|
||||
|
||||
Captured from a ponytail (lazy-senior) audit of this design. **Not decided** — to weigh
|
||||
during implementation planning. Nothing here overrides the choices in the body above.
|
||||
Deferred features, captured so they aren't lost:
|
||||
|
||||
### Candidate v1 simplifications (revisit when planning each milestone)
|
||||
- **Drop the blocking-prompt conflict mode.** A headless daemon can't show a prompt, and it
|
||||
contradicts "never asks." The `on-conflict` hook + `devbox conflicts` already cover "tell
|
||||
me." [§7]
|
||||
- **Collapse the 4 conflict-notification modes to 1.** Conflict copies on disk + `devbox
|
||||
status` badge + the `on-conflict` hook (the real notification API). Pull the mine/theirs/
|
||||
both/edit resolver to v2. [§7]
|
||||
- **Replace manager/member roles + grants table + flag clamping with a per-mount `readonly`
|
||||
flag.** v1 is single-owner; the only real need is "deploy boxes don't push." Full role/ACL
|
||||
machinery is multi-user (a §2 non-goal) arriving early. [§6, §16]
|
||||
- **One transport instead of two.** HTTP/2 blobs + WebSocket events = two reconnect/backoff
|
||||
paths. Consider HTTP/2 + SSE, or WebSocket for both. [§3, §5]
|
||||
- **Content-address the manifest from day one** (or store deltas) instead of a full gzipped
|
||||
BLOB per snapshot — avoids storing the whole path→chunks map on every push. [§16]
|
||||
- **Reconsider bash-on-Windows.** Forcing bash makes every Windows user install git-bash/WSL
|
||||
before hook #1; PowerShell is zero-install. Trades user setup friction for our convenience.
|
||||
[§10, §12]
|
||||
|
||||
### Candidate features (v2 unless promoted)
|
||||
- **LAN peer chunk-exchange + bandwidth cap.** 40 nodes pulling one big change from the hub
|
||||
over WAN saturates its uplink; co-located nodes should swap chunks directly (Syncthing-style).
|
||||
- **Default-on secret protection.** A built-in deny-list that hard-refuses to upload matched
|
||||
secret patterns even if `.devignore` is misconfigured — not just an optional `pre-push` hook.
|
||||
- **`devbox deploy <share> <snapshot>`.** Surface immutable snapshots as pinnable, atomically-
|
||||
flippable targets for read-only mounts (blue/green for `/var/www` boxes).
|
||||
- **Laptop sanity:** pause-on-metered / pause-on-battery / scheduled sync windows.
|
||||
- **Hub `/metrics` + status page.** Prometheus metrics + health (shares, devices online,
|
||||
storage, conflicts, GC). Fleet observability now; commercial-tier dashboard seam later.
|
||||
- **LAN peer chunk-exchange.** Co-located nodes swap chunks directly (Syncthing-style block
|
||||
exchange) instead of all hitting the hub — the real fix for cluster uplink pressure.
|
||||
- **Interactive conflict resolver.** `devbox conflicts` gains diff + keep-mine/theirs/both/edit.
|
||||
- **Re-share / delegation permission** (the `s` bit) — device-to-device granting.
|
||||
- **Content-level 3-way text merge** for conflicting edits.
|
||||
- **Laptop power sanity** — pause-on-metered / pause-on-battery / scheduled sync windows.
|
||||
- **Client-side E2E chunk encryption** — hub stores only ciphertext.
|
||||
- **Hub clustering / HA.**
|
||||
- **Full TUI** for `devbox` (no-arg dashboard).
|
||||
```
|
||||
|
|
|
|||
Loading…
Reference in a new issue