By default only the team owner and people who manage a vault can create vaults, as before. A hub run with LUNE_VAULT_CREATION=anyone lets any active member create one (and upload one); the creator is Manage on that vault only. Sharing is unchanged: inviting or granting still needs Manage on the vault being shared, so nobody can connect others to a vault they do not manage. An unknown value stops the hub at startup, before any data is touched. All three places that report or enforce the rule (me, canvas, create_vault) read the same setting. No client change is needed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
254 lines
23 KiB
Markdown
254 lines
23 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. |
|
||
| E · Agents' brains | **8. My agents share one GBrain** *(draft, after M7)* | Codex adds a page on the laptop; Hermes's GBrain finds it on the VPS a minute later without anyone running anything. Both write the same page at once: GBrain still sees one page, not two. |
|
||
|
||
Only the current milestone gets detailed below. The next one is detailed when the current one is accepted.
|
||
|
||
---
|
||
|
||
## 6. Milestone 7 — The app normal people install
|
||
|
||
Milestones 1–6 (sync, safety checks, the hub, taking access back, the canvas) are built; their detail lives in the code and tests now.
|
||
|
||
### Goal
|
||
Someone who has never opened a terminal installs Lune on a Mac from the team's website, connects without typing a code, and from then on only notices it in the menu bar. Updates arrive on their own, signed. Uninstalling leaves nothing behind except notes that never got shared.
|
||
|
||
This milestone ships **macOS (Apple silicon) only** (§8). The code stays portable; Windows, Linux and Intel Macs come after the pilot.
|
||
|
||
### What a person does
|
||
- Opens their invite link (or the team canvas → **Get the Mac app**) → downloads `Lune.dmg` → drags Lune to Applications → opens it.
|
||
- Back on the page, clicks **Open Lune to join** (invite) or **Connect this Mac** (already on the team). Lune opens, shows the device name it will use (editable) → **Join** / **Connect**. No code to copy.
|
||
- Picks where shared vaults live (default `~/Vaults`) → vaults arrive.
|
||
- The menu-bar icon shows the worst status: synced, waiting, offline, held secret (same colours as X6). Its menu: status line, **Open Lune**, **Open team canvas**, **Share now**, **Uninstall Lune…**, **Quit**.
|
||
- The Lune window lists vaults with plain status and anything that needs them: a held big change (**Share anyway** / **Undo**), a possible secret (**Replace with a pointer** / **Not a secret**), notes to tidy (**Compare** side by side → keep this Mac's, the other, or both).
|
||
- When a new version is published, Lune downloads it quietly and the menu says **Restart to update**.
|
||
- **Uninstall Lune…** asks once, then: shares what it can, removes the vault folders Lune created, signs this Mac out of the hub, removes its settings and login item, and moves the app to the Trash.
|
||
|
||
### Behavior
|
||
- **One engine**: the app runs the same sync engine as `lunesync run`, in-process. Both share one config, so the CLI still works next to the app. Lune starts at login once connected.
|
||
- **Connecting without a code**: the web page asks the hub for a short-lived pairing code (signed-in person) or uses the invite token, and opens `lune://pair?…` / `lune://join?…`. Typing a hub address and code in the window stays as a fallback.
|
||
- **Releases** (D3): `lunehub release keygen` creates the update-signing key on the hub's server (password-protected, never leaves it). `lunehub release publish` takes a built app, signs it there, and makes it the version the hub offers for download and update. The app trusts only that public key.
|
||
- **Too-old clients** (D3): every client says its version in its User-Agent. The hub serves the newest published version and the one before it. Older clients are refused with "Update Lune to keep syncing" and keep saving locally. Clients that don't say a version (0.1.x CLI, plain Git) are let through.
|
||
- **Several hubs on one device**: a Mac (or server) can belong to more than one team, e.g. Sen's own hub and a workplace hub. Each connection has its own device key; vaults from all of them sync side by side, and leaving one team never touches another's vaults.
|
||
- **One signing key for every hub**: releases are signed once where the key lives; other hubs `lunehub release import` an already-signed release and never hold the key.
|
||
- **Uninstall** never loses work: a vault with changes that couldn't be shared (offline, held, read-only) keeps its folder, and the dialog says which. Folders Lune didn't create are never deleted (A9).
|
||
- **Unsigned pilot** (D4): the first open needs "Open Anyway" in System Settings; the download page says so. OS code signing comes before a wider rollout.
|
||
|
||
### Acceptance — Sen acts this out
|
||
1. From an invite link on a Mac that has never run Lune: download, install, **Open Lune to join**, pick a folder; the team's vaults arrive and the menu bar shows synced.
|
||
2. On the canvas of an existing member: **Connect this Mac** pairs it with no code typed.
|
||
3. A possible secret: the menu bar turns red; resolve it from the window.
|
||
4. Same lines edited on two devices: compare side by side in the window, keep one.
|
||
5. Publish a new version on the hub: the app picks it up, **Restart to update**, and comes back as the new version still synced.
|
||
6. **Uninstall Lune…**: vault folders it created and its settings are gone, the device disappears from the canvas, and a folder you added yourself is untouched.
|
||
|
||
### Out of scope for M7
|
||
Windows and Linux installers, Intel Macs, server install script (D2), OS code signing (D4), security audit and release evidence (before a wider rollout, not the pilot).
|
||
|
||
## 6b. Milestone 8 — My agents share one GBrain *(draft, queued after M7)*
|
||
|
||
### Goal
|
||
A vault that GBrain (https://github.com/garrytan/gbrain) uses as its brain syncs through Lune without making that brain messy. Every device's agent answers from the latest notes, and a clash never shows up in GBrain as a second copy of a page.
|
||
|
||
Why: GBrain indexes every Markdown file, so S4's `name (Label's version).md` becomes a duplicate page; and no device refreshes its GBrain index after notes arrive.
|
||
|
||
### What a person does
|
||
- Marks a vault as a GBrain brain, in the canvas or the window (`lunesync vault kind <vault> gbrain`). Lune suggests it when it finds `gbrain.yml` or `.gbrain-source` in the vault. The vault shows a "GBrain" badge.
|
||
- On each device where the `gbrain` command is found, the vault shows "Refresh GBrain after sync: on" (asked once). After that the person never runs GBrain commands themselves.
|
||
|
||
### Behavior
|
||
GBrain vaults only; Obsidian vaults behave exactly as before.
|
||
- **Refresh after sync.** After a sync that brought changes, Lune runs `gbrain sync --source <name> --no-pull` in the background (Lune does the pulling; GBrain only reads committed files by default, and Lune commits every burst). The source name is per device and defaults to the vault name. Lune looks for `gbrain` in the usual install places, not only the shell's PATH. It never holds up syncing. If it fails, the vault shows amber "GBrain not refreshed" with **Retry**.
|
||
- **Both sides added lines in the same spot** → keep both, incoming first, then this device's. No clash copy.
|
||
- **Same lines changed on both sides** → the incoming version stays in place. This device's version is not written into the vault folder; it is kept on this device, outside the vault's files (inside `.git/`, which GBrain never reads), under **Notes to tidy** (window, canvas, `lunesync tidy`) until resolved. This applies everywhere Lune would otherwise keep both copies (syncing, undo, handovers, held notes).
|
||
- **The vault's kind is set on the hub**, so every device agrees. A GBrain vault therefore has to live on a Lune hub, not a plain Git remote.
|
||
- **Ignore defaults**: `.gbrain-source` (a per-device source pin). `gbrain.yml` is shared.
|
||
- The secret check (P2) and the runaway guard (S6) apply as before.
|
||
|
||
### Acceptance — Sen acts this out
|
||
1. Mark Brain as a GBrain brain. Laptop "Codex" and VPS "Hermes" both point GBrain at their copy.
|
||
2. Codex adds a page. Within about a minute `gbrain query` on the VPS finds it, with nothing run by hand.
|
||
3. Both agents append to the same page's timeline at once: the page has both entries, and there is no copy file.
|
||
4. Both rewrite the same paragraph: one stays, the other waits under Notes to tidy on its own device. `gbrain query` on either device returns one page. Tidy it and the result reaches both.
|
||
5. Break GBrain on the VPS (rename the binary): the vault turns amber, notes keep syncing, and Retry works after fixing it.
|
||
6. An Obsidian vault next to it behaves as before, including `(Label's version).md` copies.
|
||
|
||
### Out of scope for M8
|
||
Installing or running GBrain for people, MCP through Lune, hosted gbrain.io, a shared Supabase database, parsing GBrain page sections.
|
||
|
||
### Open questions for M8
|
||
1. Whether GBrain's upkeep (dream cycle, `gbrain maintain`) trips the runaway guard and needs a per-vault "trust big rewrites from this device" switch. Decide after a real GBrain run on Brain.
|
||
2. GBrain can write into the vault itself: it edits a managed block in `.gitignore` after each sync, and its default (mixed) mode can create and commit pages. Lune would share those like any edit. Confirm that's fine on a real run, or suggest `GBRAIN_NO_GITIGNORE=1`.
|
||
|
||
## 7. Open questions
|
||
None open for M7. M8's are in §6b.
|
||
|
||
## 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)
|
||
- 2026-10-29 — Web canvas sign-in (new): no passwords; a one-time link from `lunesync open` or a pairing code typed on the hub's sign-in page; 30-day session cookie. (Sen)
|
||
- 2026-10-29 — Milestone 7 ships macOS (Apple silicon) only; Windows, Linux and Intel Macs after the pilot (D1). (Sen)
|
||
- 2026-10-29 — The update-signing key lives on the hub's server and `lunehub` signs releases there, so losing a laptop doesn't lose the key (D3). (Sen)
|
||
- 2026-10-29 — A device can connect to several hubs at once (Sen's own and a workplace hub), each with its own device key (A1, new in M7). (Sen)
|
||
- 2026-10-29 — One update-signing key, on Sen's VPS, signs releases for every hub; other hubs import signed releases (D3). Accepted trade-off: that server is trusted by every hub's Macs. (Sen)
|
||
- 2026-10-29 — Leaving a team (new): a device can leave a team's hub itself (`lunesync leave`, the app's Leave), handing over first; a hub that's gone can be forgotten locally, folders kept. (Sen, after testing)
|
||
- 2026-10-29 — Deleting a vault (new, team owner): everyone is removed the usual way (handover, then copies removed), the history stays archived on the hub and the name is freed. Asks for confirmation, like Remove from team (X2). (Sen, after testing)
|
||
- 2026-10-29 — Moving a vault onto a hub (new): the team owner and anyone with Manage on a vault may create vaults, so they may upload one too (the app's **Upload**, `lunesync vault upload`). Only a vault that's on that device alone goes up; one on its own remote (GitHub, GitLab…) is **detached** first, and a check-in no longer moves a same-named vault off its own remote silently. Avoids one vault's notes living in two places (A3). (Sen)
|
||
- 2026-10-29 — A vault's settings decide where it shares: a folder found pointing elsewhere is set back. A leaving device whose older history has a possible secret hands over its current notes as one entry with those lines replaced, instead of never finishing (A6, P3). (Sen, after the Brain mix-up)
|
||
- 2026-10-29 — Uploading checks everything first, the way the hub will: a vault on one device only holds every line that looks like a secret for a decision; "not a secret" marks travel to the team; history with one goes up as a fresh start. Nothing is made on the team until it passes. A vault on one device joins a same-named team vault only if they share history; otherwise the team's arrives beside it (P2, P3). (Sen, after the Brain upload)
|
||
- 2026-10-29 — Community release without Apple signing, under AGPL-3.0-only; the public repo stays at git.senkensha.space. (Sen)
|
||
- 2026-11-16 — For GBrain vaults, S4 changes: the losing version of a same-lines clash is kept only on its own device under Notes to tidy, never written into the vault folder; lines both sides added are kept, incoming first (S4, M8). (Sen)
|
||
- 2026-11-16 — A vault's kind (Obsidian / GBrain) is a hub setting, so a GBrain vault must be on a hub; Brain moves from Gitea to the hub before M8's acceptance (M8). (Sen)
|
||
- 2026-11-17 — Who may create vaults is a hub setting, `LUNE_VAULT_CREATION`: `managers` (the default, as decided 2026-10-29: the team owner and anyone with Manage on a vault) or `anyone`. Any member can create vaults when LUNE_VAULT_CREATION=anyone; creators are Manage on their own vault only; sharing still needs Manage on the vault being shared. The same rule covers uploading a vault, and an unknown value stops the hub at start. (Sen)
|