Milestone 2: secret check and runaway guard
Notes with a likely secret on a new line are held on the device (own short rule list, per SPEC §8); `lunesync held pointer|not-secret` resolves them. Bursts removing or rewriting a big part of the vault are saved but not shared until `lunesync held share|undo`. Incoming edits to a held note land in place with the held version kept beside it. Adds `tidy show` and SPEC §6 detail for M2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
65
docs/SPEC.md
65
docs/SPEC.md
@@ -153,57 +153,48 @@ Only the current milestone gets detailed below. The next one is detailed when th
|
||||
|
||||
---
|
||||
|
||||
## 6. Milestone 1 — My machines share one vault
|
||||
## 6. Milestone 2 — It catches my mistakes
|
||||
|
||||
Milestone 1 (sync through a plain Git remote, `lunesync` CLI) is built; its detail lives in the code and tests now.
|
||||
|
||||
### Goal
|
||||
Sen's laptop and VPS keep one vault in sync through an ordinary Git remote (e.g. a private GitHub repo or a bare repo on the VPS). No hub, no accounts yet. This alone fixes the Codex/Hermes drift and becomes a daily-use tool immediately.
|
||||
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.
|
||||
|
||||
### What Sen does
|
||||
```bash
|
||||
# on each machine
|
||||
lunesync device name Codex # or Hermes on the VPS
|
||||
lunesync add DevOps ~/Vaults/DevOps --remote git@github.com:sen/devops-vault.git
|
||||
lunesync run # foreground, to watch it work
|
||||
lunesync service install # later: keep it running (launchd / systemd)
|
||||
|
||||
# anytime
|
||||
lunesync status
|
||||
lunesync checkpoint "updated VM list"
|
||||
lunesync tidy # list notes with kept-both versions
|
||||
lunesync tidy keep mine|theirs|both <file>
|
||||
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
|
||||
```
|
||||
`add` on an empty folder clones; on a folder that already holds a vault, it adopts it (initial commit, then sync). Existing vaults are never reorganized.
|
||||
`status` and the `run` log say when something is held.
|
||||
|
||||
### Behavior
|
||||
- **Watch → settle → commit → sync**: file watcher; a burst ends after ~5 s of quiet or at 60 s max; only settled files are included; one commit per burst, author = device label.
|
||||
- **Sync** = fetch, merge, push. Retries with backoff. Offline: commits pile up locally, `status` shows "Waiting to sync · N changes".
|
||||
- **Conflicts** (S4): never leave conflict markers in files; never stop syncing. `tidy` resolves.
|
||||
- **Ignore by default**: `.obsidian/workspace*.json`, `.obsidian/cache`, `.trash/`, OS junk (`.DS_Store`, `Thumbs.db`). Everything else, including binaries and other `.obsidian/` files, syncs byte-for-byte.
|
||||
- **No line-ending or case rewriting.** Bytes in = bytes out. Two paths differing only by case are reported, not silently merged.
|
||||
- **Marker** inside `.git/` identifies folders the app manages (needed later for safe deletion, A9).
|
||||
- `status` per vault: Synced just now / Waiting N / Offline / N notes to tidy, plus last sync time.
|
||||
|
||||
### Tech choices (implementation defaults — record changes)
|
||||
- Rust. Git via `git2` with vendored libgit2 (mature merge support, no system Git needed). `notify` for file watching. TOML config in the OS config dir.
|
||||
- Credentials for the Git remote in M1: whatever the user's SSH agent / Git credential setup already provides. The hub replaces this in M3.
|
||||
- **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.
|
||||
|
||||
### Acceptance — Sen acts this out
|
||||
1. Laptop edits `vm-list.md`; within ~10 s the VPS folder has it and Hermes can read it.
|
||||
2. Hermes (or a script) rewrites 14 notes in a burst; history shows one entry labeled Hermes.
|
||||
3. Laptop goes offline, 3 notes edited; `status` shows waiting; reconnect; VPS catches up with no action.
|
||||
4. Both edit the same lines of `runbook.md` while one is offline; after sync both versions exist, nothing is lost, sync kept running; `tidy keep both|mine|theirs` cleans it up.
|
||||
5. Adopting an existing Obsidian vault preserves every file and folder exactly (compare checksums before/after).
|
||||
6. Obsidian open on the vault the whole time: no churn from workspace files, no broken notes.
|
||||
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`.
|
||||
|
||||
### Out of scope for M1
|
||||
Secret check and runaway guard (M2), hub/accounts/devices (M3), any UI beyond the CLI.
|
||||
### Out of scope for M2
|
||||
The hub-side check (P3) and anything with accounts: M3.
|
||||
|
||||
---
|
||||
|
||||
## 7. Open questions (not blocking M1)
|
||||
## 7. Open questions
|
||||
- Hub storage for repos: plain bare repos on disk vs. something like Gitea underneath (decide at M3).
|
||||
- Secret detection rules: embed a known ruleset (gitleaks-style) vs. our own short list (decide at M2).
|
||||
|
||||
## 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)
|
||||
|
||||
Reference in New Issue
Block a user