lunehub serves accounts, invites, pairing codes, memberships, devices and vaults as plain bare repos (SPEC §8), checks device key and role on every Git request, refuses secrets in a pre-receive hook (P3) and logs every access change. Ships as one container (Dockerfile, compose.yaml). lunesync gains join, login, pair, vault new/upload, invite, grant, members and hub log; `run` picks up new vaults and roles from the hub. Read members' edits stay local. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
212 lines
16 KiB
Markdown
212 lines
16 KiB
Markdown
# Lune — Spec
|
||
|
||
Owner: Sen · Draft 1 · 28 Oct 2026
|
||
Product name: **Lune**. CLI: `lunesync` (the name `lune` is already taken by a Luau runtime in Homebrew and crates.io).
|
||
|
||
This is the single source of truth. If the code and this document disagree, one of them is wrong — raise it with Sen, don't silently pick one.
|
||
|
||
Visual companions (Sen's private links):
|
||
- Blueprint (journeys, decisions, milestones): https://claude.ai/artifact/SRS6qmUupZEBdAdi7NL6nc
|
||
- Clickable prototype (team canvas, menu-bar app, join flow): https://claude.ai/artifact/Fu42uR9nextfov7tTiXadS
|
||
|
||
---
|
||
|
||
## 1. Vision
|
||
|
||
**One vault. Every copy current. Access you can take back.**
|
||
|
||
People and their AI agents keep knowledge in ordinary Markdown vaults (Obsidian-compatible folders). This app keeps every copy of a shared vault in sync, makes access easy to grant and take back, and hides all the technical work (Git, merging, keys) behind a simple, playful interface.
|
||
|
||
It started from a real problem: a DevOps vault shared with a team through a Git repo. It worked, but only for people comfortable with Git, local work sometimes never reached the team, and there was no clean way to cut off someone who left. The same problem shows up with one person's own agents: Codex on a laptop and Hermes on a VPS drifting out of sync.
|
||
|
||
### North-star test
|
||
Every feature must serve at least one of:
|
||
1. **Sync you can trust** — work reaches everyone, nothing is lost, nothing blocks.
|
||
2. **Access as a lifecycle** — grant, change and take back access cleanly.
|
||
3. **Approachable** — someone who has never heard of a vault can use it.
|
||
|
||
If a feature serves none of these, it waits.
|
||
|
||
### v1 in one sentence
|
||
Me, my agents and a small team share vaults reliably.
|
||
|
||
---
|
||
|
||
## 2. How it fits together
|
||
|
||
- **Hub** — a server Sen hosts (Docker on a VM). Holds each vault as a Git repo, plus accounts, memberships, devices and the access log. Serves the web canvas.
|
||
- **Sync app** — one Rust program installed on every machine. Two modes:
|
||
- *Desktop*: menu-bar app (Tauri) for macOS, Windows, Linux.
|
||
- *Headless*: CLI + background service for servers and agent hosts.
|
||
- **Plain folders in between** — every person and agent works in a normal local folder. Obsidian, Codex, Hermes or any editor just read and write files. No plugin or agent integration is required.
|
||
- **Web canvas** — where access is managed: grant, revoke, sync health, removing someone from the team.
|
||
|
||
Repo layout (one repo, one language for logic):
|
||
```
|
||
core/ sync engine, Git, conflicts, secret check, runaway guard, hub client (Rust)
|
||
cli/ thin command layer over core (Rust)
|
||
hub/ server: accounts, memberships, devices, repos, access log (Rust)
|
||
web/ canvas UI (React), also reused inside the desktop window
|
||
desktop/ Tauri shell: tray icon + small window, calls core
|
||
```
|
||
|
||
---
|
||
|
||
## 3. Decisions
|
||
|
||
Settled. Changing one needs Sen's explicit OK, recorded here with the date.
|
||
|
||
### Sync
|
||
| # | Decision |
|
||
|---|---|
|
||
| S1 | Git is the version layer, bundled inside the app. Users never install or see Git. No custom VCS, no CRDT. |
|
||
| S2 | Edits are shared after ~5 s with no writes, never later than ~60 s even if writing never stops. Each burst becomes one history entry. Files are only picked up once they stop changing. |
|
||
| S3 | Optional named checkpoints (`lunesync checkpoint "msg"`). Agents can be told to use them. |
|
||
| S4 | Conflicts: merge line by line when possible. Same lines changed → keep both: the incoming version stays in place, the local one is saved beside it as `name (Label's version).md`. Sync never blocks waiting for a human. |
|
||
| S5 | Offline: changes queue as local commits and go out when the network is back. |
|
||
| S6 | Runaway guard: a burst that deletes or rewrites ~20% of a vault or ~50+ notes is held for the device owner to confirm (Share anyway / Undo). Applies to every device. |
|
||
| S7 | Each history entry is labeled with the device it came from. |
|
||
|
||
### Access
|
||
| # | Decision |
|
||
|---|---|
|
||
| A1 | Three layers: **account** (a person), **membership** (access to one vault, many per person), **device** (one key per device, removable on its own). |
|
||
| A2 | No separate agent concept. Agents run on devices; devices have labels the owner chooses (e.g. laptop "Codex", VPS "Hermes"). Every device gets its owner's role. A per-device read-only switch may come later. |
|
||
| A3 | Roles per membership: **Read**, **Edit**, **Manage**. A Read member's local edits stay local with a clear "not shared, you have read access" note; files are not locked on disk. |
|
||
| A4 | One invite per person (one-time link). They add their own devices by pairing code. |
|
||
| A5 | Removing someone from a vault affects that vault only. Their account and other vaults keep working. |
|
||
| A6 | On removal: the device makes the folder read-only, runs a **final sync** of unshared changes into a **handover area** (reviewed by a manager: Keep / Discard), and only after the hub confirms receipt does it delete the folder. Offline devices do this on reconnect. A manager can force "Delete without saving". |
|
||
| A7 | "Delete from their devices" is a per-vault setting, on by default. |
|
||
| A8 | **Remove from team** is a separate, deliberate flow: team owners only, ends every membership and device, account is disabled (restorable), history keeps their name. Permanent deletion is a later admin action. |
|
||
| A9 | The app only ever deletes folders it created, verified by a marker inside `.git/`, never following links out. |
|
||
| A10 | Every access change is logged automatically by the hub. No manual checklists for external tools. |
|
||
| A11 | Known limit, always stated honestly: copies made elsewhere, or content already given to other tools, can't be recalled. |
|
||
|
||
### Safety
|
||
| # | Decision |
|
||
|---|---|
|
||
| P1 | **Pointers, not secrets.** Vaults never store credentials. Notes say where to get access ("use tsh", "search X in Secrets Manager"). |
|
||
| P2 | Secret check runs on every change before it leaves a device. A hit holds the whole note's change locally. Options: Replace with a pointer / Not a secret (remembered for that exact line). |
|
||
| P3 | The hub runs the same check and rejects pushes containing secrets (catches edits made outside the app). |
|
||
| P4 | The app never grants SSH, cloud, repo or deployment access. That stays in Teleport, IAM, secret managers, etc. |
|
||
|
||
### Distribution and updates
|
||
| # | Decision |
|
||
|---|---|
|
||
| D1 | Laptops: native installers (`.dmg`, `.exe`/`.msi`, `.AppImage`/`.deb`), downloaded from the hub's website, paired automatically after sign-in. |
|
||
| D2 | Servers: one-line install script + `lunesync login --code … --name …` + `lunesync service install`. |
|
||
| D3 | The hub decides which app version to offer; updating the hub rolls out the matching client. Updates are always signed (Tauri updater). Hub supports at least one older client version. Too-old clients keep saving locally and show "Update to keep syncing". |
|
||
| D4 | Unsigned builds are fine for an internal pilot. OS code signing before wider rollout. |
|
||
| D5 | Uninstall removes the app's vault folders. On macOS the app has its own Uninstall menu item. |
|
||
|
||
### Experience (from the prototype round)
|
||
| # | Decision |
|
||
|---|---|
|
||
| X1 | The canvas is the page: full-screen, no page scroll. Controls float on top. The details panel appears only when something is selected and the canvas shrinks to make room (bottom sheet on phones). |
|
||
| X2 | **Gestures are symmetric.** Grant = drag a vault onto a person. Revoke = pull a ribbon until it pinches and snaps. No confirmation dialog for either; revoke shows a toast with **Undo** (~8 s) and nothing reaches the person's devices until the undo window passes. Only "Remove from team" asks for confirmation. |
|
||
| X3 | Every gesture has a button alternative in the panel. |
|
||
| X4 | Ribbons are real metaballs (SVG blur + alpha-threshold "goo" filter), drawn center to center under the nodes, so ribbons and node halos merge smoothly. |
|
||
| X5 | Each vault and person has an **identity color**; ribbons fade from vault color to person color. Identity colors avoid green, amber and grey. |
|
||
| X6 | **Status colors are reserved:** green = current, amber = behind / needs a decision, grey = offline. **Red = something sensitive almost leaked** (secret caught). Nothing else uses red. |
|
||
| X7 | Hover or selection focuses a node: its ribbons and connected nodes stay bright, the rest fades. Dimmed nodes use a veil, never transparency. |
|
||
| X8 | Float (gentle bobbing, all on one shared animation clock) and Dock (tidy grid). Reduced motion: no bobbing, instant transitions. |
|
||
| X9 | Plain words everywhere. Never "commit", "push", "merge", "branch" in the UI. |
|
||
| X10 | How-to instructions appear only as a first-run onboarding card, never as permanent panel text. |
|
||
| X11 | Panels have back navigation; each view remembers where it was opened from. |
|
||
| X12 | Mobile: no mobile app in v1. The web canvas stays usable on a phone for urgent actions (revoke, nudge, remove from team). |
|
||
|
||
---
|
||
|
||
## 4. Non-goals
|
||
|
||
Never, by design:
|
||
- Storing or managing secrets.
|
||
- Granting SSH, cloud, repo or deployment access.
|
||
- Replacing Obsidian with our own editor.
|
||
- Our own version control system.
|
||
|
||
Not in v1 (later, maybe):
|
||
- Mobile sync; Obsidian plugin; MCP access for agents; browser-only read view.
|
||
- Time-limited access; folder-level access inside a vault; SSO.
|
||
- Installable PWA; vault templates; per-device read-only switch.
|
||
- Verifying removal in external tools (Teleport, GitHub).
|
||
|
||
Also not now: security audits, CVE sweeps, release evidence, multi-arch packaging. These belong right before a real release (Milestone 7), not during the MVP.
|
||
|
||
---
|
||
|
||
## 5. Milestones
|
||
|
||
Four targets, seven milestones. Each ends with a story Sen acts out as a user. A milestone is done when the story works, not when the code compiles.
|
||
|
||
| Target | Milestone | Story to act out |
|
||
|---|---|---|
|
||
| A · Core + CLI | **1. My machines share one vault** | Edit a note on the laptop; Hermes reads it on the VPS. Go offline, keep editing, reconnect, it catches up. Edit the same lines on both: both versions kept. Synced through a plain Git remote, no hub. |
|
||
| | **2. It catches my mistakes** | Paste a fake AWS key: held back, replace with a pointer. Script deletes half the vault: held for confirmation, undo. Tidy a conflict from the CLI. |
|
||
| B · Hub | **3. Shared with my team** | Run the hub in Docker, invite a teammate, they pair a device with a code, the vault arrives. Label the VPS "Hermes" and see its edits labeled. |
|
||
| | **4. Access I can take back** | Remove someone from a vault: their unshared work arrives as a handover, then their copy disappears, other vaults keep working. Remove someone from the team: everything stops. All via CLI admin commands. |
|
||
| C · Web | **5. Canvas for access** | Grant by drag, revoke by pinch with undo, button alternatives, invites, device labels, Float/Dock. |
|
||
| | **6. Canvas for health and leaving** | Freshness glow and Nudge, tidy a conflict side by side, review a handover, remove from team — also from a phone. |
|
||
| D · Desktop | **7. The app normal people install** | Download from the website, pair automatically, pick a folder, tray status, compare a conflict, receive an update, uninstall cleanly. |
|
||
|
||
Only the current milestone gets detailed below. The next one is detailed when the current one is accepted.
|
||
|
||
---
|
||
|
||
## 6. Milestone 3 — Shared with my team
|
||
|
||
Milestones 1–2 (sync over a Git remote, secret check, runaway guard) are built; their detail lives in the code and tests now.
|
||
|
||
### Goal
|
||
A hub Sen runs in Docker replaces the plain Git remote. People get in by invite, add their own devices by pairing code, and every vault they're a member of arrives on its own. Roles are enforced by the hub, not by trust.
|
||
|
||
### What Sen does
|
||
```bash
|
||
# on the VM
|
||
docker compose up -d # hub; first start prints the owner invite link in the log
|
||
# on the laptop
|
||
lunesync join https://hub.example/join/… --name Codex
|
||
lunesync vault upload DevOps # the M1 vault moves onto the hub, history kept
|
||
lunesync invite Alice --vault DevOps:edit # one-time link for Alice
|
||
lunesync pair # prints a ready-to-paste login line with a short code
|
||
# on the VPS
|
||
lunesync login --hub https://hub.example --code K7QD-4MXA --name Hermes
|
||
lunesync run # DevOps arrives in ~/Vaults/DevOps
|
||
# anytime
|
||
lunesync vault new Notes | grant Alice Notes --role read | members DevOps | hub log
|
||
```
|
||
Alice runs `lunesync join <link> --name "Alice laptop"`, then `lunesync run`: DevOps arrives.
|
||
|
||
### Behavior
|
||
- **Hub** = one container: an HTTP API plus Git over HTTPS for vaults, SQLite and bare repos on one volume (`/data`). It listens on plain HTTP; TLS comes from Sen's reverse proxy. `LUNE_HUB_URL` is the public address used in links.
|
||
- **Accounts, memberships, devices (A1)**. The hub has one team; the first account is its **owner**. Owners create vaults; owners and a vault's **Manage** members invite and grant for that vault.
|
||
- **Invites (A4)**: one per person, a one-time link that names the person and the vaults + roles they get, valid 7 days. Accepting it creates the account and its first device.
|
||
- **Pairing**: a signed-in device asks for a code (8 characters, 10 minutes, single use); a new device logs in with it and gets its own key. Devices never share keys. A device key is shown once and stored in the device's config file (owner-only permissions); the hub stores only its hash.
|
||
- **Vaults arrive**: while `run` is going, the device checks the hub every 30 s and adds any vault it's now a member of, under `~/Vaults/<name>` (`--vaults-dir` to change). Vaults from M1 with a plain Git remote keep working.
|
||
- **Roles (A3)** are enforced by the hub on every Git request: Read can only receive changes. A Read member's own edits stay local; `status` says "not shared — you have read access".
|
||
- **Device labels (S7)**: chosen at join/login, renamed with `lunesync device name` (updates the hub too). History entries carry the label.
|
||
- **Hub secret check (P3)**: every incoming change is scanned with the same rules, commit by commit, before the hub accepts it. A hit is refused with the note, line and rule. "Not a secret" on a device is also sent to the hub for that vault.
|
||
- **Upload** keeps history. If old history contains a secret the hub refuses it; `vault upload --fresh` uploads only the current notes as a fresh start (the old history stays on that device only).
|
||
- **Access log (A10)**: the hub records invites created and accepted, devices paired and renamed, vaults created, memberships granted, and refused changes. `lunesync hub log` (owner).
|
||
|
||
### Acceptance — Sen acts this out
|
||
1. `docker compose up -d` on a fresh VM; the owner link from the log works once and only once.
|
||
2. Upload the real DevOps vault; history and every file survive (checksums).
|
||
3. Pair the VPS with a code as "Hermes"; DevOps arrives; its edits show up labeled Hermes.
|
||
4. Invite a teammate with Edit on DevOps; they join, the vault arrives, their edits reach Sen.
|
||
5. Grant someone Read: the vault arrives, their edits stay local with the note, the hub refuses them even if pushed by hand.
|
||
6. Edit a note with a fake key directly in a hub vault from outside the app (plain `git push` with a device key): refused.
|
||
|
||
### Out of scope for M3
|
||
Removing people or devices, handovers (M4). Any web UI (M5). Client updates from the hub (M7).
|
||
|
||
## 7. Open questions
|
||
None open.
|
||
|
||
## 8. Decision changes
|
||
Record here: date, what changed, why, which decision number. Example:
|
||
`2026-11-02 — S2 cap raised from 60 s to 90 s: VPS bursts too chatty. (Sen)`
|
||
|
||
- 2026-10-28 — Secret detection (open question, P2): our own short list of ~20 high-confidence rules, not an embedded gitleaks-style set. Fewer false alarms, easy to read. (Sen)
|
||
- 2026-10-29 — Hub storage (open question): plain bare repos on the hub's volume served by the hub itself (device key + role check, then Git's own HTTP backend); no Gitea underneath. (Sen)
|