Milestone 3: the hub
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>
This commit is contained in:
61
docs/SPEC.md
61
docs/SPEC.md
@@ -153,48 +153,59 @@ Only the current milestone gets detailed below. The next one is detailed when th
|
||||
|
||||
---
|
||||
|
||||
## 6. Milestone 2 — It catches my mistakes
|
||||
## 6. Milestone 3 — Shared with my team
|
||||
|
||||
Milestone 1 (sync through a plain Git remote, `lunesync` CLI) is built; its detail lives in the code and tests now.
|
||||
Milestones 1–2 (sync over a Git remote, secret check, runaway guard) are built; their detail lives in the code and tests now.
|
||||
|
||||
### Goal
|
||||
The sync engine stops the two mistakes that hurt most before they reach anyone else: a secret pasted into a note, and a script that wipes or rewrites a big part of the vault. Both are held on the device where they happened; everything else keeps syncing.
|
||||
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
|
||||
lunesync held # what's held back and why
|
||||
lunesync held pointer <file> "search prod-deploy in Secrets Manager" # replace the secret with a pointer
|
||||
lunesync held not-secret <file> [--line N] # it isn't a secret; remembered for that exact line
|
||||
lunesync held share # the big change was intended: share it anyway
|
||||
lunesync held undo # it wasn't: bring everything back
|
||||
lunesync tidy show <file> # compare the two kept versions before picking one
|
||||
# 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
|
||||
```
|
||||
`status` and the `run` log say when something is held.
|
||||
Alice runs `lunesync join <link> --name "Alice laptop"`, then `lunesync run`: DevOps arrives.
|
||||
|
||||
### Behavior
|
||||
- **Secret check (P2)** runs on every saved burst, before a change becomes history, so a held change can never leave the device. Only lines new to the note are checked. A hit holds that whole note's change (it stays unsaved in the folder); the rest of the burst is shared as usual. Binary files are skipped.
|
||||
- **Rules**: our own short list of ~20 high-confidence patterns (AWS keys, private key blocks, GitHub/GitLab/Slack/Stripe/Google/OpenAI/Anthropic/npm/DigitalOcean/SendGrid/Telegram/Vault tokens, JWTs, passwords inside URLs, and `password|secret|token|api_key = <long random value>`). Output never prints a full secret, only a masked hint.
|
||||
- **Pointer**: replaces just the secret text with the pointer text. **Not a secret**: remembered per device as a hash of that exact line (no secret text stored), in `.git/lune/`. The hub gets its own copy of this list in M3.
|
||||
- **Incoming changes to a held note** don't wait: the held local version moves beside the note as `name (Label's version).md` (still held), the incoming version lands in place. Same rule as S4.
|
||||
- **Runaway guard (S6)**: a burst is held if it deletes or heavily rewrites (more than half the lines gone) at least 50 notes, or at least 20% of the vault's notes and at least 5. Renames and moves don't count. The burst is saved locally as history (so Undo is exact), but nothing from this device is shared while it's held; incoming changes still arrive.
|
||||
- **Share anyway** releases it. **Undo** adds a history entry that brings back exactly what the burst removed or rewrote; if someone else edited one of those notes meanwhile, both versions are kept. Then both entries are shared, so other devices see no change.
|
||||
- **Tidy** gets `show`: a line-by-line comparison of the note and its kept copy.
|
||||
- **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. Paste `AKIAIOSFODNN7EXAMPLE` into `aws.md` while other notes are being edited: the other notes reach the VPS, `aws.md` doesn't; `status` and the log say why; `held pointer aws.md "…"` replaces it and the note is shared.
|
||||
2. A line that only looks like a secret: `held not-secret` releases it and it's never flagged again on that device.
|
||||
3. A script deletes half the vault: nothing reaches the VPS; `held undo` brings every file back byte-exact; the VPS never loses a note.
|
||||
4. A deliberate big cleanup: `held share` sends it.
|
||||
5. Edit the same lines on both machines, `tidy show`, then `tidy keep`.
|
||||
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 M2
|
||||
The hub-side check (P3) and anything with accounts: M3.
|
||||
### Out of scope for M3
|
||||
Removing people or devices, handovers (M4). Any web UI (M5). Client updates from the hub (M7).
|
||||
|
||||
## 7. Open questions
|
||||
- Hub storage for repos: plain bare repos on disk vs. something like Gitea underneath (decide at M3).
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user